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: */

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 20:53:06
Script start
Timing: Jan 18 2025 20:53:06
Module start 'layout'
Timing: Jan 18 2025 20:53:06
Module start 'content'
Timing: Jan 18 2025 20:53:07
Module end 'content'
Timing: Jan 18 2025 20:53:07
Script end

Main resources:

Total runtime0.7665 sec
Peak memory usage4,096.0000 KB
Database Queries68

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 589.0703152.6250
Module start 'layout' 0.00510.0026 741.695339.4453
Module start 'content' 0.00760.7574 781.1406598.9766
Module end 'content' 0.76500.0015 1,380.117216.1563
Script end 0.7665  1,396.2734 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.4458160.0002
Check MTime0.00130.1757160.0001
Mysql Total
Database connection0.00070.090210.0007
Mysqli_queries0.692990.3990680.0102
Looping result0.00070.0956660.0000
Template Total0.720494.020.3602
Template load0.00230.305520.0012
Template processing0.718093.667520.3590
Template load and register function0.00010.016710.0001
states
state_id_array0.00080.103210.0008
state_identifier_array0.00100.131420.0005
Override
Cache load0.00190.2530270.0001
Sytem overhead
Fetch class attribute can translate value0.00090.115730.0003
Fetch class attribute name0.00170.226570.0002
XML
Image XML parsing0.00300.392330.0010
class_abstraction
Instantiating content class attribute0.00010.007970.0000
General
dbfile0.01932.5137160.0012
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 19
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs