close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Grouping related products in cart

Thread began 1/29/2018 5:30 pm by Dave Buchholz | Last modified 4/02/2019 12:46 pm by Ray Borduin | 743 views | 5 replies |

Dave BuchholzBeta Tester

Grouping related products in cart

I have a situation where I would like the ability to group related products in the cart display together regardless of when they were entered in the cart, I can add a column to the cart to add the parent sku but does eCart have the ability to do something like this ?

Sign in to reply to this post

Ray BorduinWebAssist

There is nothing inherent in eCart that will do this for you. But the cart is just stored in an array in the session, so you can use a php sorting function to re-order the array.

Sign in to reply to this post

Dave BuchholzBeta Tester

That’s a good idea I never thought of that, I will have a play and see what I can do, there may be more questions later

Thanks

Sign in to reply to this post

Dave BuchholzBeta Tester

Ray,

I am resurrecting this old thread as I have only just got back to this !

So when I print_r the ecart object like so:

print '<pre>';
print_r($eCart1);
print '</pre>';


this is an example of what I see

eCart1_Definition Object
(
[CartName] => eCart1
[PersistanceType] => 0
[CurrencyAlign] => 0
[CurrencyPrefix] => $
[DecimalPlacesC] => 2
[DecimalPlacesW] => 2
[DisplayIndex] => 0
[ForceDecimalsC] => 1
[ForceDecimalsW] => 1
[NumberDisplay] => 0
[WeightAlign] => 1
[ChargesDisplayIndex] => 0
[DiscountsDisplayIndex] => 0
[TaxDisplayIndex] => 0
[ShippingDisplayIndex] => 0
[Charges] => Array
(
)

[Discounts] => Array
(
)

[Tax] => Array
(
)

[Shipping] => Array
(
)

[ShippingIsTaxed] =>
[cartAction] =>
[redirStr] =>
[CurrencyCode] => USD
[WeightSuffix] => oz
[Columns] => Array
(
[0] => Array
(
[0] => ID
[1] => N
)

[1] => Array
(
[0] => Name
[1] => T
)

[2] => Array
(
[0] => Description
[1] => T
)

[3] => Array
(
[0] => Thumbnail
[1] => T
)

[4] => Array
(
[0] => Weight
[1] => W
)

[5] => Array
(
[0] => Quantity
[1] => N
)

[6] => Array
(
[0] => Price
[1] => C
)

[7] => Array
(
[0] => SKU
[1] => T
)

[8] => Array
(
[0] => Options
[1] => T
)

[9] => Array
(
[0] => DiscountApplied
[1] => I
)

[10] => Array
(
[0] => DiscountShown
[1] => I
)

[11] => Array
(
[0] => MoreDetails
[1] => I
)

[12] => Array
(
[0] => Shipping
[1] => I
)

[13] => Array
(
[0] => Taxable
[1] => I
)

[14] => Array
(
[0] => BrandURMP
[1] => I
)

[15] => Array
(
[0] => Discountable
[1] => I
)

[16] => Array
(
[0] => ParentSKU
[1] => T
)

[17] => Array
(
[0] => ProductType
[1] => N
)

)

[Items] => Array
(
[0] => eCart1_ItemDefinition Object
(
[ID] => 3357
[Name] =>
[Description] => Dishwasher with Triple Filter Wash System - black
[Thumbnail] => https://www.specsserver.com/CACHE/FRQMDJISYEAY.JPG?width=300&height=300
[Weight] => 0
[Quantity] => 1
[Price] => 389
[SKU] => ADB1400AGB
[Options] =>
[DiscountApplied] => 0
[DiscountShown] => 0
[MoreDetails] => 0
[Shipping] => 0
[Taxable] => 0
[BrandURMP] => 0
[Discountable] => 0
[ParentSKU] => ADB1400AGB
[ProductType] => 1
[WAUID] => 155405352322625746
[TotalWeight] => 0
[TotalPrice] => 389
[FullDetails] => 1 (3357)
)

[1] => eCart1_ItemDefinition Object
(
[ID] => 9
[Name] => Dishwasher Install Kit & Adapter (Required)
[Description] => Purchased with ADB1400AGB
[Thumbnail] => /_site-files/img/cart-pages/no-image.jpg
[Weight] => 0
[Quantity] => 1
[Price] => 29.99
[SKU] => DW-INSTALL-KIT
[Options] =>
[DiscountApplied] => 0
[DiscountShown] => 0
[MoreDetails] =>
[Shipping] => 0
[Taxable] => 1
[BrandURMP] => 0
[Discountable] => 0
[ParentSKU] => ADB1400AGB
[ProductType] => 3
[WAUID] => 155405352322722055
[TotalWeight] => 0
[TotalPrice] => 29.99
[FullDetails] => 1 Dishwasher Install Kit & Adapter (Required) (9)
)

[2] => eCart1_ItemDefinition Object
(
[ID] => 406
[Name] =>
[Description] => GE Cafe™ Series 30" Slide-In Front Control Range with Warming Drawer
[Thumbnail] => https://www.specsserver.com/CACHE/FRQULVSTJSHK.JPG?width=300&height=300
[Weight] => 0
[Quantity] => 1
[Price] => 2499
[SKU] => CGS986SELSS
[Options] =>
[DiscountApplied] => 0
[DiscountShown] => 0
[MoreDetails] => 0
[Shipping] => 0
[Taxable] => 0
[BrandURMP] => 0
[Discountable] => 0
[ParentSKU] => CGS986SELSS
[ProductType] => 1
[WAUID] => 155405372861825180
[TotalWeight] => 0
[TotalPrice] => 2499
[FullDetails] => 1 (406)
)

[3] => eCart1_ItemDefinition Object
(
[ID] => 4
[Name] => Gas Line Install Kit (Required)
[Description] => Purchased with CGS986SELSS
[Thumbnail] => /_site-files/img/cart-pages/no-image.jpg
[Weight] => 0
[Quantity] => 1
[Price] => 27.99
[SKU] => COOKING-GAS-LINE
[Options] =>
[DiscountApplied] => 0
[DiscountShown] => 0
[MoreDetails] =>
[Shipping] => 0
[Taxable] => 1
[BrandURMP] => 0
[Discountable] => 0
[ParentSKU] => CGS986SELSS
[ProductType] => 3
[WAUID] => 155405372861975651
[TotalWeight] => 0
[TotalPrice] => 27.99
[FullDetails] => 1 Gas Line Install Kit (Required) (4)
)

)

)



what I want is to be able to access the [items] array so that I can order them based on the ParentSKU and ProductType fields, how can I do that ?

Or should I be looking at the session $_SESSION['eCart1_Items'] ?
I am still having issues with exploding this so

$temp = explode("§WA§",$_SESSION['eCart1_Items']);


gives me

Array
(
[0] => 3357|WAECART||WAECART|Dishwasher with Triple Filter Wash System - black|WAECART|https://www.specsserver.com/CACHE/FRQMDJISYEAY.JPG?width=300&height=300|WAECART|0|WAECART|1|WAECART|389|WAECART|ADB1400AGB|WAECART||WAECART|0|WAECART|0|WAECART|0|WAECART|0|WAECART|0|WAECART|0|WAECART|0|WAECART|ADB1400AGB|WAECART|1|WAECART|155405352322625746|WAECART|0|WAECART|389|WAECART|1 (3357)�WA�9|WAECART|Dishwasher Install Kit & Adapter (Required)|WAECART|Purchased with ADB1400AGB|WAECART|/_site-files/img/cart-pages/no-image.jpg|WAECART|0|WAECART|1|WAECART|29.99|WAECART|DW-INSTALL-KIT|WAECART||WAECART|0|WAECART|0|WAECART||WAECART|0|WAECART|1|WAECART|0|WAECART|0|WAECART|ADB1400AGB|WAECART|3|WAECART|155405352322722055|WAECART|0|WAECART|29.99|WAECART|1 Dishwasher Install Kit & Adapter (Required) (9)�WA�406|WAECART||WAECART|GE Cafe™ Series 30" Slide-In Front Control Range with Warming Drawer|WAECART|https://www.specsserver.com/CACHE/FRQULVSTJSHK.JPG?width=300&height=300|WAECART|0|WAECART|1|WAECART|2499|WAECART|CGS986SELSS|WAECART||WAECART|0|WAECART|0|WAECART|0|WAECART|0|WAECART|0|WAECART|0|WAECART|0|WAECART|CGS986SELSS|WAECART|1|WAECART|155405372861825180|WAECART|0|WAECART|2499|WAECART|1 (406)�WA�4|WAECART|Gas Line Install Kit (Required)|WAECART|Purchased with CGS986SELSS|WAECART|/_site-files/img/cart-pages/no-image.jpg|WAECART|0|WAECART|1|WAECART|27.99|WAECART|COOKING-GAS-LINE|WAECART||WAECART|0|WAECART|0|WAECART||WAECART|0|WAECART|1|WAECART|0|WAECART|0|WAECART|CGS986SELSS|WAECART|3|WAECART|155405372861975651|WAECART|0|WAECART|27.99|WAECART|1 Gas Line Install Kit (Required) (4)
)



which is an issue I think I have mentioned before.

Any help is greatly appreciated.

Thanks,

Dave Buchholz
I-CRE8 Limited

Sign in to reply to this post

Ray BorduinWebAssist

You can just access the $eCart1->Items array directly and sort it in place, or save it and sort it separately.

You could use something like:

php:
<?php

$sortedArray 
$eCart1->Items;

function 
cartSort($a,$b) {
  return (
$a->ParentSKU $b->ParentSKU)?-1:1;
}

usort($sortedArray"cartSort");
?>



Then the $sortedArray would be sorted by the ParentSKU.

Sign in to reply to this post

Dave BuchholzBeta Tester

Thanks Ray,

after some experimentation this is what I ended up with

if (!function_exists("cartSort")) { /* see http://www.webassist.com/forums/post/219584/ */
function cartSort($a,$b) {
return ($a->ParentSKU > $b->ParentSKU)?1:-1; // sorts a - z
return ($a->ProductType > $b->ProductType)?-1:1; // sorts 1 - 3
}
}


then adding

usort($eCart1->Items, "cartSort");


after

$eCart1->GetContent();


like so

<?php
$eCart1->GetContent();
usort($eCart1->Items, "cartSort");
?>


gives me exactly what I am looking for.

Thanks again.

Best Regards,

Dave Buchholz
I-CRE8 Limited

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...