Forums / Setup & design / Order 2 products at the same time

Order 2 products at the same time

Author Message

Bertrand Dunogier

Tuesday 12 July 2005 8:55:16 am

I'm running in a funny & tricky problem with eZ Publish 3.6 for an e-commerce site.

The website offers among other things contact lenses. They have various options (doptry, color...). So far, everything's fine. Now the problem is that these options can be chosen differently for both eyes ;)

When someone adds lenses with different options for left & right eye, the same product is ordered twice, with different options, one for each eye.

I don't think it is possible to achieve that out of the box. I was thinking about adding an action to the shop module like AddMultipleItemsToBasket, and transfer 2 object IDS with their respective option when different options are chosen.

Do you see a better approach ? Any suggestion is appreciated.

Mads Ovesen

Wednesday 28 September 2005 6:41:02 am

Hi Bertrand,
I'm in need of the same kind of solution. I have no better solution than the one suggested. It seems like the most reasonable way to do it. Did you make it work??

- Mads

/m

Bertrand Dunogier

Wednesday 28 September 2005 6:55:12 am

Yes, I have a working solution.

It's a light hack on the AddToBasket action. It allows you to define options using a subindex, like

eZOption[set_right][2010]

if eZOption[set_right][2010] and eZOption[set_left][2010] are different, 2 products are added, otherwise one is added.

I can provide you with the patch if you want, but it comes with no warranty ;)

Mads Ovesen

Wednesday 28 September 2005 7:25:50 am

Thanks. I would like to see the patch, so I can modify it to fit my needs.

/m

Xavier Dutoit

Monday 03 October 2005 1:07:15 am

It also would be great if you could post the diff in this thread for later reference...

X+

http://www.sydesy.com

Bertrand Dunogier

Tuesday 04 October 2005 5:00:38 am

Here is the patch for eZ Publish 3.6.0 stable

--- kernel/shop/ezshopoperationcollection.orig.php      2005-10-04 13:50:53.000000000 +0200
+++ kernel/shop/ezshopoperationcollection.php   2005-08-19 14:28:12.000000000 +0200
@@ -88,6 +88,18 @@
             eZDebug::writeError( 'Attempted to add object without price to basket.' );
             return array( 'status' => EZ_MODULE_OPERATION_CANCELED );
         }
+
+        /* Check if options are part of a set */
+        $set = false;
+        foreach ( array_keys( $optionList ) as $optionKey ) {
+            if ( substr( $optionKey, 0, 4 ) == 'set_' ) {
+                $returnStatus = eZShopOperationCollection::addToBasket( $objectID, $optionList[$optionKey] );
+                $set = true;
+            }
+        }
+        if ( $set )
+            return array( 'status' => $returnStatus );
+
         $basket =& eZBasket::currentBasket();
 
         /* Check if the item with the same options is not already in the basket: */

eZ debug

Timing: Jan 31 2025 04:31:43
Script start
Timing: Jan 31 2025 04:31:43
Module start 'content'
Timing: Jan 31 2025 04:31:43
Module end 'content'
Timing: Jan 31 2025 04:31:43
Script end

Main resources:

Total runtime0.1805 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 587.9531180.8281
Module start 'content' 0.00540.0120 768.781398.0078
Module end 'content' 0.01740.1630 866.7891526.5781
Script end 0.1804  1,393.3672 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00331.8312200.0002
Check MTime0.00130.7090200.0001
Mysql Total
Database connection0.00050.285310.0005
Mysqli_queries0.106659.04921410.0008
Looping result0.00130.69821390.0000
Template Total0.162590.110.1625
Template load0.00080.459310.0008
Template processing0.161789.588010.1617
Override
Cache load0.00060.330310.0006
Sytem overhead
Fetch class attribute can translate value0.00060.348010.0006
XML
Image XML parsing0.00020.110310.0002
General
dbfile0.030716.9898200.0015
String conversion0.00000.003330.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs