• Register
Plug-in Tutorial Build an EC-CUBE plug-in

Top Commentators

114

1

EC Mike

SHOGUNSHOGUN

32

2

hrbabu

SAMURAISAMURAI

29

3

Sumant Jha

SAMURAISAMURAI

29

4

justcubed

SAMURAISAMURAI

21

5

Ashok Kafle

SAMURAISAMURAI

21

6

shahith

SAMURAISAMURAI

14

7

Jeemusu

KABUKIKABUKI

14

8

Yangsin

KABUKIKABUKI

9

9

Zaw Hlaing Bwar

GEISYAGEISYA

8

10

Fei Liu

GEISYAGEISYA

Ranking Key

  • FUJISANFUJISAN1,000+ posts
  • SAKURASAKURA500+ posts
  • SHOGUNSHOGUN100+ posts
  • NINJYANINJYA50+ posts
  • SAMURAISAMURAI20+ posts
  • KABUKIKABUKI10+ posts
  • GEISYAGEISYALess than 10 posts

Add multiple products to the cart with one button

0 votes

Has anyone had any luck implementing similar functionality? 

I would like to be able to create products that contain multiple sub products. The idea being that when you click the add to cart button for that product, it will add those multiple sub products to the cart in one go.

I am currently thinking the best way to implement this would be to duplicate the Related Products functionality in the Add Products section of the CMS. The only difference would be allowing you to set a quantity, and the product_class_id for each sub product.

I could then change the button in the templates so that it submits any products with sub products with a new mode, say 'add_multiple_cart' instead of 'cart'. I could then change the doCart() function in LC_Page_Products_Details_Ex.php, and add in a loop for each sub product around the line:

$objCartSess->addProduct($product_class_id, $this->objFormParam->getValue('quantity')); 

The only thing thats bugging me is how to implement the error checks on the products. I figured I could skip doing a check for each sub product if I ensured that the parent product had the same sock quantity as the sub child with the least stock? 

Would this be a sound approach to implement the desired functionality? Is there anything I've overlooked?
 

asked 2013-05-09 by Jeemusu (690 points) KABUKIKABUKI

1 Answer

0 votes
Jeemusu,

Sounds like a solid plan. As for the error check, I would define a max limit of sub items, and create a loop:

function lfInitParam(&$objFormParam) {
for($i = 1; $i <= $this->maxItems; $i ++) {
$objFormParam->addParam('subitem(' . $i . ')', 'subitem_' . $i, MTEXT_LEN, 'KVa',     array('MAX_LENGTH_CHECK'));
}
}

 

Let me know if you got it working!

Thanks,

Michael
answered 2013-05-13 by EC Mike (6,360 points) SHOGUNSHOGUN
...