mercredi 7 octobre 2015

WooCommerce: Display ONLY discounted product in list

From this question WooCommerce: Display ONLY on-sale products in Shop I tried to display product those are discounted. But every time it's displaying all products those are on_sale . I also tried _sale_price meta key. But can't understand how can I solve my problem. My project output from my code enter image description here

My $args variable

$args = array(
'post_type'      => 'product',
'order'          => 'ASC',
'meta_query'     => array(
    array(
        'key'           => '_sale_price',
        'value'         => 0,
        'compare'       => '>',
        'type'          => 'numeric'
    )
)
);

I also tried below code. But same result

$args = array(
'post_type'      => 'product',
'posts_per_page' => 8,
'meta_query'     => array(
    'relation' => 'OR',
    array( // Simple products type
        'key'           => '_sale_price',
        'value'         => 0,
        'compare'       => '>',
        'type'          => 'numeric'
    ),
    array( // Variable products type
        'key'           => '_min_variation_sale_price',
        'value'         => 0,
        'compare'       => '>',
        'type'          => 'numeric'
    )
)
);



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire