Jump to content

Hook and variables


Recommended Posts

Hi everyone,

we are using the version 1.6.1.19.

I want to customize the "$minimal_quantity" value.

Below is a portion of the Cart.php updateQty() function (function starting at line 911).  At the bottom of the code there is a call to a hook actionBeforeCartUpdateQty.  What I would like to do is have a module hoked to that call (actionBeforeCartUpdateQty) and override the $minimal_quantity.  Is this something doable since the $minimal_quantity is not passed to the hook?

 

 

        /* If we have a product combination, the minimal quantity is set with the one of this combination */
        if (!empty($id_product_attribute)) {
            $minimal_quantity = (int)Attribute::getAttributeMinimalQty($id_product_attribute);
        } else {
            $minimal_quantity = (int)$product->minimal_quantity;
        }

        if (!Validate::isLoadedObject($product)) {
            die(Tools::displayError());
        }

        if (isset(self::$_nbProducts[$this->id])) {
            unset(self::$_nbProducts[$this->id]);
        }

        if (isset(self::$_totalWeight[$this->id])) {
            unset(self::$_totalWeight[$this->id]);
        }

        Hook::exec('actionBeforeCartUpdateQty', array(
            'cart' => $this,
            'product' => $product,
            'id_product_attribute' => $id_product_attribute,
            'id_customization' => $id_customization,
            'quantity' => $quantity,
            'operator' => $operator,
            'id_address_delivery' => $id_address_delivery,
            'shop' => $shop,
            'auto_add_cart_rule' => $auto_add_cart_rule,
        ));

Or maybe the only way is by overriding the function?

 

Thanks!!

hook.PNG

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...