Jump to content

Overwrite Cart updateQty method problem


Kirnau
 Share

Recommended Posts

Hi,

 

I want to override the updateQty method in Cart class.

So I've made a file Cart.php in override/classes.

<?php

Class Cart extends CartCore {

    public function updateQty($quantity, $id_product, $id_product_attribute = null, $id_customization = false, $operator = 'up', $id_address_delivery = 0, Shop $shop = null, $auto_add_cart_rule = true) {
        parent::updateQty($quantity, $id_product, $id_product_attribute, $id_customization, $operator, $id_address_delivery, $shop, $auto_add_cart_rule);
        // custom code in future
    }
}

Now I have the problem if I want to add an article to cart, I always get an notification that the max quantity for this article already reached.

If I comment out the method, the product will add to cart normally.

 

Can somebody explain me where is the failure and why this message occurs and how to make this overwrite method working?

 

Thank you.

 

Share this post


Link to post
Share on other sites

Hi,

 

I want to override the updateQty method in Cart class.

So I've made a file Cart.php in override/classes.

<?php

Class Cart extends CartCore {

    public function updateQty($quantity, $id_product, $id_product_attribute = null, $id_customization = false, $operator = 'up', $id_address_delivery = 0, Shop $shop = null, $auto_add_cart_rule = true) {
        parent::updateQty($quantity, $id_product, $id_product_attribute, $id_customization, $operator, $id_address_delivery, $shop, $auto_add_cart_rule);
        // custom code in future
    }
}

Now I have the problem if I want to add an article to cart, I always get an notification that the max quantity for this article already reached.

If I comment out the method, the product will add to cart normally.

 

Can somebody explain me where is the failure and why this message occurs and how to make this overwrite method working?

 

Thank you.

Can you please use this

<?php

Class Cart extends CartCore {

    public function updateQty($quantity, $id_product, $id_product_attribute = null, $id_customization = false, $operator = 'up', $id_address_delivery = 0, Shop $shop = null, $auto_add_cart_rule = true) {
        parent::updateQty();
        // custom code in future
    }
}

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More