| @@ -240,11 +240,17 @@ | ||
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | $i = 0; |
| 243 | 243 | |
| 244 | - foreach ( $products as $product ) { | |
| 244 | + global $product; | |
| 245 | + $isGlobalProduct = false; | |
| 246 | + if ( $product instanceof WC_Product ) { | |
| 247 | + $isGlobalProduct = $product; | |
| 248 | + } | |
| 249 | + | |
| 250 | + foreach ( $products as $_product ) { | |
| 245 | 251 | $i++; |
| 246 | - $GLOBALS['product'] = $product; | |
| 252 | + $GLOBALS['product'] = $_product; | |
| 247 | 253 | $layout = RenderHelpers::filter_layout( esc_html( $settings['layout'] ), $template ); |
| 248 | 254 | |
| 249 | 255 | /** |
| 250 | 256 | * Before product template render hook. |
| @@ -251,9 +257,9 @@ | ||
| 251 | 257 | */ |
| 252 | 258 | do_action( 'rtsb_before_product_template_render' ); |
| 253 | 259 | |
| 254 | 260 | // Loop arg. |
| 255 | - $arg = $this->arg_dataset( $settings, $product, $settings['lazy_load'], $i ); | |
| 261 | + $arg = $this->arg_dataset( $settings, $_product, $settings['lazy_load'], $i ); | |
| 256 | 262 | |
| 257 | 263 | // Get template. |
| 258 | 264 | $html .= Fns::load_template( $template . $layout, $arg, true ); |
| 259 | 265 | |
| @@ -263,9 +269,11 @@ | ||
| 263 | 269 | do_action( 'rtsb_after_product_template_render' ); |
| 264 | 270 | |
| 265 | 271 | unset( $GLOBALS['product'] ); |
| 266 | 272 | } |
| 267 | - | |
| 273 | + if ( $isGlobalProduct ) { | |
| 274 | + $GLOBALS['product'] = $isGlobalProduct; | |
| 275 | + } | |
| 268 | 276 | return $html; |
| 269 | 277 | } |
| 270 | 278 | |
| 271 | 279 | /** |