我想获取可变产品的计划日期销售,并尝试编码
function sales_timer_echo_product_from() {
global $product;
if( $product->is_type('variable') ){
$sale_price_dates = get_post_meta($variation_id->get_date_on_sale_from(), '_sale_price_dates_from', true );
$sale_price_dates_from = get_post_meta($variation_id->get_date_on_sale_to(), '_sale_price_dates_to', true );
//global $post;
//$regular_price = get_post_meta( $post->ID, '_sale_price_dates_to', true );
if(!empty($sale_price_dates_from)) {
echo '<div class="countdown-container" id="sales_timer_display_from'.$variation_id->get_date_on_sale_from().'" data-date-from="'.date("Y-m-d H:i:s",$sale_price_dates_from).'"></div>';
}
}
}
和
function sales_timer_echo_product_from() {
global $product;
if( $product->is_type('variable') ){
$sale_price_dates = get_post_meta( $product->get_id(), '_sale_price_dates_to', true );
$sale_price_dates_from = get_post_meta( $product->get_id(), '_sale_price_dates_from', true );
//global $post;
//$regular_price = get_post_meta( $post->ID, '_sale_price_dates_to', true );
if(!empty($sale_price_dates_from)) {
echo '<div class="countdown-container" id="sales_timer_display_from'.$product->get_id().'" data-date-from="'.date("Y-m-d H:i:s",$sale_price_dates_from).'">
}
}
}
我尝试更改此设置,但没有希望,或者我错了什么
$date_from = isset( $variation['sale_price_dates_from'] ) ? strtotime( $variation['sale_price_dates_from'] ) : get_post_meta($variation_id, '_sale_price_dates_from', true);
$date_to = isset( $variation['sale_price_dates_to'] ) ? strtotime( $variation['sale_price_dates_to'] ) : get_post_meta($variation_id, '_sale_price_dates_to', true);
它们不适用于可变产品,请帮助我解决此问题。