Merge pull request #14940 from woocommerce/fix/14825
reset post data prevents grouped products working in shortcodes
This commit is contained in:
commit
fbb8b56202
|
@ -13,7 +13,7 @@
|
||||||
* @see https://docs.woocommerce.com/document/template-structure/
|
* @see https://docs.woocommerce.com/document/template-structure/
|
||||||
* @author WooThemes
|
* @author WooThemes
|
||||||
* @package WooCommerce/Templates
|
* @package WooCommerce/Templates
|
||||||
* @version 3.0.3
|
* @version 3.0.6
|
||||||
*/
|
*/
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
exit;
|
exit;
|
||||||
|
@ -28,12 +28,13 @@ do_action( 'woocommerce_before_add_to_cart_form' ); ?>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
$quantites_required = false;
|
$quantites_required = false;
|
||||||
|
$previous_post = $post;
|
||||||
|
|
||||||
foreach ( $grouped_products as $grouped_product ) {
|
foreach ( $grouped_products as $grouped_product ) {
|
||||||
$post_object = get_post( $grouped_product->get_id() );
|
$post_object = get_post( $grouped_product->get_id() );
|
||||||
$quantites_required = $quantites_required || ( $grouped_product->is_purchasable() && ! $grouped_product->has_options() );
|
$quantites_required = $quantites_required || ( $grouped_product->is_purchasable() && ! $grouped_product->has_options() );
|
||||||
|
|
||||||
setup_postdata( $GLOBALS['post'] =& $post_object );
|
setup_postdata( $post =& $post_object );
|
||||||
?>
|
?>
|
||||||
<tr id="product-<?php the_ID(); ?>" <?php post_class(); ?>>
|
<tr id="product-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||||
<td>
|
<td>
|
||||||
|
@ -79,7 +80,7 @@ do_action( 'woocommerce_before_add_to_cart_form' ); ?>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
wp_reset_postdata();
|
$post = $previous_post;
|
||||||
?>
|
?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
Loading…
Reference in New Issue