Jump to content

Edit History

WisQQ

WisQQ

Hello,
After shoppingcart module upgrade to 3.0.0 version, there is a bug which passes object to smarty compilation instead of array. Because of that site will break when trying to render cart widget.
To fix this issue, you have to change object to array inside this function:
image.thumb.png.4e959d5fb5deb9dd447b7eb557b288c3.png

    /**
     * Provides an already presented object from the context if set.
     * If not, runs the presenter.
     *
     * @return array presented cart
     */
    private function getPresentedCart()
    {
        /*
         * We will use the already presented cart in the first place. It should be already in the template.
         * Check FrontController::assignGeneralPurposeVariables for more information.
         *
         * If it's not, we will present the cart ourselves. There will always be a cart object
         * assigned in FrontController::init.
         */
        if (!empty($this->context->smarty->getTemplateVars('cart'))) {
            return (array)$this->context->smarty->getTemplateVars('cart');
        } else {
            return (new CartPresenter())->present($this->context->cart);
        }
    }

$this->context->smarty->getTemplateVars('cart'); returns object instead of array, but functions should return array.

WisQQ

WisQQ

Hello,
After shoppingcart module upgrade to 3.0.0 version, there is a bug which passes object to smarty compilation instead of array. Because of that site will break when trying to render cart widget.
To fix this issue, you have to change object to array inside this function:
image.thumb.png.4e959d5fb5deb9dd447b7eb557b288c3.png

public function getWidgetVariables($hookName, array $params)
    {
        return [
            'cart' => (array)$this->getPresentedCart(),
            'refresh_url' => $this->context->link->getModuleLink('ps_shoppingcart', 'ajax', [], null, null, null, true),
            'cart_url' => $this->getCartSummaryURL(),
        ];
    }

 

×
×
  • Create New...