Skip to content

Commit

Permalink
Merge pull request woocommerce#14940 from woocommerce/fix/14825
Browse files Browse the repository at this point in the history
reset post data prevents grouped products working in shortcodes
  • Loading branch information
claudiulodro authored May 8, 2017
2 parents e92b93f + 36f7823 commit fbb8b56
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions templates/single-product/add-to-cart/grouped.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 3.0.3
* @version 3.0.6
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
Expand All @@ -28,12 +28,13 @@
<tbody>
<?php
$quantites_required = false;
$previous_post = $post;

foreach ( $grouped_products as $grouped_product ) {
$post_object = get_post( $grouped_product->get_id() );
$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(); ?>>
<td>
Expand Down Expand Up @@ -79,7 +80,7 @@
</tr>
<?php
}
wp_reset_postdata();
$post = $previous_post;
?>
</tbody>
</table>
Expand Down

0 comments on commit fbb8b56

Please sign in to comment.