Page 1 of 1

Add to Cart with Options for Different Product

Posted: Sat Jul 30, 2016 7:11 am
by andrewtite
Hi, I have a mod working that allows products as options, and if selected in the setup, can override the main product when added to the cart. This solves the problem of having for example a red, blue, and green item with different part numbers and inventory counts.

It's working perfectly, the only thing is when there is a regular option on the main product that applies to all the other variation products (blue item, red item, etc), it won't add the option to the cart.

I'm using this to determine if it's a product option to override the main one.

Code: Select all

if (!$override) {  $this->cart->add($product_id, $quantity, $option, $recurring_id); }

if ($override) {
     $this->cart->add($product_as_option_value['product_id'], $product_product_option_value['quantity'], $option, $recurring_id);
} else {
     $this->cart->add($product_as_option_value['product_id'], $product_product_option_value['quantity'], array(), $recurring_id);
}
As you can see, I used the $option variable from the main product if it is an override product so it will pick up the main product option(s) and add them.

It's regognizing that there is an option because it's adding a new line if i select a different option and adding quantity if i select the same option. It's just not actually showing up on the view cart page or order. I think it's because the options in the database are product specific and I can't figure out how to add the product option if it isn't associated to the same product. I even tried copying the options and that didn't work either.

I'm really stuck here.
}