/** * Adds some standard render contexts for pulled regions. * * @param AjaxHTTPResponse $response * @param Buyable $buyable [optional] */ protected function setupRenderContexts(AjaxHTTPResponse $response, $buyable = null) { if ($this->owner->hasMethod('Cart')) { $cart = $this->owner->Cart(); if ($cart instanceof ViewableData) { $response->addRenderContext('CART', $this->owner->Cart()); } } if ($buyable) { $response->addRenderContext('BUYABLE', $buyable); // this could be a Product or ProductVariation (or something else) // but we want a render target available for the product specifically // for rendering ProductGroupItem in a category or search view if ($buyable instanceof Product) { $response->addRenderContext('PRODUCT', $buyable); } elseif ($buyable->hasMethod('Product')) { $response->addRenderContext('PRODUCT', $buyable->Product()); } } }
/** * Adds some standard render contexts for pulled regions. * * @param AjaxHTTPResponse $response * @param GroupedProduct $groupedProduct * @param Form $form */ protected function setupRenderContexts(AjaxHTTPResponse $response, $groupedProduct, $form) { if ($this->owner->getController()->hasMethod('Cart')) { $cart = $this->owner->getController()->Cart(); if ($cart instanceof ViewableData) { $response->addRenderContext('CART', $this->owner->getController()->Cart()); } } $response->addRenderContext('PRODUCT', $groupedProduct); $response->addRenderContext('FORM', $form); }