Release showing a drop-down list of options in a custom template using the WPeCommerce 3.8.9.2 plugin

I am having trouble displaying changes in a custom template, every time I call the wpsc wpsc_have_variation_groups() function in my loop, I get the following php error

commerce / wpsc-includes / product-template.php on line 1419 [22-Nov-2012 23:27:39] PHP Fatal error: call the have_variation_groups() member have_variation_groups() on a non-object in / home / tofapost / public _html / sandbox / wp / wp-content / plugins / wp-e-commerce / wpsc-includes / product-template.php on line 1419.

wpsc_have_variation_groups() is called inside a WP_Query loop as follows:

 $args = array('post_type' => 'wpsc-product', 'posts_per_page' => -1); $loop = new WP_Query($args); while ($loop->have_posts()) : $loop->the_post(); ... <?php if (wpsc_have_variation_groups()) { ?> <?php } ?> ... endwhile; 

It is strange that other wpsc functions such as wpsc_the_product_id () and wpsc_product_has_stock () work, and the functions related to the changes do not ...

Any help appreciated

thanks

+4
source share
2 answers

This has already been answered. The problem with this question is that not all code is displayed and the wrong type of loop is being used. for listing products.

The answer that was used was to manually obtain the options, because the type of the loop does not allow the use of the identifier, since there was no identifier of the variations that needed to be obtained. In order to be able to use the current code, he needs to use another cycle or change it so that the change is manually received. In this case, the change was manually received.

 global $wpsc_variations; $wpsc_variations = new wpsc_variations( get_the_ID() ); 

Link: https://wordpress.stackexchange.com/questions/73689/issue-displaying-variations-in-custom-template-using-wpec-3-8-9-2

+2
source

The wpsc_the_product () function sets the global $ wpsc_variations object, which uses the product change functions.

I think that to use wpsc_the_product () you need your query as a global $ wp_query, but you can configure $ wpsc_variations yourself after you open your loop:

 while ($loop->have_posts()) : $loop->the_post(); global $wpsc_variations; $wpsc_variations = new wpsc_variations( get_the_ID() ); 

We hope that all product variation features will work.

You can go to the following location:

https://wordpress.stackexchange.com/questions/73689/issue-displaying-variations-in-custom-template-using-wpec-3-8-9-2

I think this will help you solve your problem.

+2
source

Source: https://habr.com/ru/post/1447924/


All Articles