We have dokan + woocommerce running platform. Currently when user update sale price from vendor dashboard dokan, its not showing in sale page. Apparently, it shows only product that updates from woocommerce directly. So i created custom sale shortcode but still it works like that not showing all sale products.
Below, I attach the custom Shortcode. Meanwhile may I know is there any way can make WooCommerce update the products from third party plugin?
if( ! function_exists('get_preordable_products') ) {
function get_preordable_products( $atts ) {
// Shortcode Attributes
extract( shortcode_atts( array(
'columns' => '4',
'limit' => '20',
), $atts, 'preordable_products' ) );
// The WP_Query
$query = new WP_Query( array (
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => $limit,
) );
global $woocommerce_loop;
$woocommerce_loop['columns'] = $columns;
$woocommerce_loop['is_shortcode'] = 1;
$woocommerce_loop['total'] = $query->post_count;
$woocommerce_loop['total_pages'] = $query->max_num_pages;
$woocommerce_loop['per_page'] = $limit;
ob_start();
if ( $query->have_posts() ) {
woocommerce_product_loop_start();
while ( $query->have_posts() ) {
$query->the_post();
$id = get_the_ID();
$_product = wc_get_product();
if($_product->is_on_sale()){
wc_get_template_part( 'content', 'product' );
}
}
woocommerce_product_loop_end();
woocommerce_reset_loop();
wp_reset_postdata();
} else {
do_action( "woocommerce_shortcode_products_loop_no_results", $atts );
echo '<p>'. __("Aucun article disponible à la précommande.") . '</p>';
}
$content = ob_get_clean();
return '<div class="woocommerce columns-' . $columns . '">' . $content . '</div>';
}
add_shortcode( 'preordable_products', 'get_preordable_products' );
}