Monday 16 August 2010 4:52:29 am
Hi. I don't think there is a way to do that without doing your own extension. In our last project we've done something similar that could give you a hint on that. In our case, we have some kinda product packs. For being brief, suppose our shop has 100 book references. one user could want to buy 12 of them. For adding a product to your shop basket you will need at least a contentobject_id. but in our case, every book was a content object, so which one to add to the shop and how to calculate the total amount of the added pack? knowing that a contentobject_id is required for being able to add something to your basket, we created a dummy product called something like 'Books Pack'. suppose that contentobject has id = 1000 instead of usign shop/add method to add it to the basket, we created our own module and added our add to basket stuff, trying always to use methods from ez publish kernel. suppose then we have a page where 50 books are showed. user can add 10, 14, 20... whatever. every book has a checkbox with its contentobject_id as value. then we added the 'buy button' and that one will send selecteced contentobject ids to our 'add staff'. in that add staff we check which products are the ones the user wants to add to the basket. knowing that products we can go through them, getting their prices and so we get the total amount of this pack. next you only need to add the product to the basket. following ez publish you can do something like
$item = eZProductCollectionItem::create( $basket->attribute( "productcollection_id" ) );
$item->setAttribute( 'name', 'Book Pack' );
$item->setAttribute( "contentobject_id", 1000 );
$item->setAttribute( "item_count", 1 );
$item->setAttribute( "price", $total ); // total price of the packet. sum of all selected by the user
$item->setAttribute( "is_vat_inc", '0' );
$item->setAttribute( "vat_value", 4 );
$item->setAttribute( "discount", 0 ); // note that you can also use that for discount...
$item->store(); Don't know if that could give you a hint. Not that this solution probably is not perfect... for example, what about adding two packs instead of only one... but that was not our customer requirement :) You can also use that at a starting point for your stats. probably you can use an auxiliar table to save wich individual projects are being added in the product collection and when user completes the order do some stuff to increment the number of times that individual project has been sold. But as said, i don't think ez publish could solve your needs by default. don't know if xrowcommerce extension could... i haven't play with it.
|