-
-
Notifications
You must be signed in to change notification settings - Fork 506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
woocommerce.php $product = wc_get_product( $context['post'] -> ID ) cannot get correct result #1384
Comments
I tested your code in a fresh project and |
Hi |
Also having this issue |
Hi, @AlexanderBMAS
compare my old |
I’m gonna go ahead and suggest that you try out the new Timber integration for WooCommerce. From what I see, your issue could be solved if you’d use the integration like this:
Now this would probably break your sidebar. You could add it to the WooCommerce context: functions.php add_filter( 'timber/woocommerce/context', function( $context ) {
$context['sidebar'] = Timber::get_widgets( 'shop-sidebar' );
return $context;
} ); Or, you could also add it to the top of woocommerce.php: add_filter( 'timber/context', function( $context ) {
$context['sidebar'] = Timber::get_widgets( 'shop-sidebar' );
return $context;
} ); |
I follow the doc to integrate woocommerce (https://github.com/jarednova/timber/wiki/WooCommerce-Integration)
but in
single-product.twig
{% do action('woocommerce_single_product_summary') %}
can not get the correct result (it always get the same product price, add cart button point the same product )I debug display my themes woocommerce.php the `$product = wc_get_product($context['post'] -> ID)` did not get the correct result(`$product` always point the same product), then I debug `plugins/woocommerce/templates/single-product /price.php` found `global $product` always point the same product
my `woocommerce.php` code
cart page, checkout page and my_account page are use
shortcode
to show, sowoocommerce.php
only add single-product.$context['post']
display correct sing-product information,$context['post'] -> ID
display correct sing-product IDbut when do
wc_get_product( $context['post'] -> ID )
$product
always show the same product infomy `single-product.twig`
The text was updated successfully, but these errors were encountered: