T
T
tratsiaka2018-03-16 02:28:44
WordPress
tratsiaka, 2018-03-16 02:28:44

How to create a Woocommerce+Simple Auction product cycle when developing a plugin?

Hello, friends! I need help, because I'm already exhausted.
There is a bunch - WooCommerce + Woocommerce Simple Auctions.
It is necessary to sort through the products in the body of the plugin I created, select only those that are auctions and change the desired values ​​of the auction without bringing it to the front-end.
The problem is that when I use the standard product loop, it doesn't contain the necessary properties and meta fields that are related to the auction. Those. they belong to the class WC_Product_Simple and should belong to WC_Product_Auction
The thought came up that I was just hooking my loop to the wrong hook.
_CMfz6t5ctw.jpg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tratsiaka, 2018-03-17
@tratsiaka

Thanks for the answer! But it has nothing to do with the problem, unfortunately! A solution was found, the fact is that the plugin filters the standard output loop, so you need to specify additional parameters in the loop arguments:

$args = array(
        'post_type'      => 'product',
        'posts_per_page' => - 1,
        'auction_arhive' => true,
        'product_type'   => 'auction',
    );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) {
        $loop->the_post();
        $id = $post->ID;
    $item = wc_get_product( $id );
      echo '<pre>';
    		print_r($item);
    		echo '</pre>'; 
    }
    wp_reset_postdata();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question