i checked the 'cred-commerce' files. I understand there is addtocart function (referenced in 4 files) which adds '1' is default quantity.
Will it possible for you to modify api hook: 'cred_commerce_add_product_to_cart' so that we can modify quantity?
Further, there will be a field in cred form which will hold the quantity. It will be great if you can help me identify how to get that field in the above hook and use it update the quantity.
And looking into WooCommerce's API, it looks like you can filter the quantity to override the value passed to the add_to_cart method.
See hidden link
So you could use our cred_commerce_add_product_to_cart hook to intervene, setting up a callback for the woocommerce_add_to_cart_quantity filter: the $product is available in your callback for that filter, and you need $product->ID to pass to the woocommerce_add_to_cart_quantity filter to identify the product being added to the cart to know which one to change the quantity for.
As for retrieving the quantity from a field that is submitted with the form, I suggest you check the $_POST object where you should find the field and its value available.
The topic ‘[Closed] Need to modify quantity of the product that is being added via commerce form’ is closed to new replies.