Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 02-09-2017 17:22:47

CrownRoyal
Member
Registered: 01-10-2009
Posts: 716

how to apply discount on qty purchase at the shopping cart

Goal: Offer a $1.50 discount on more than one item bought in the v8 store.

I scripted this

///START QUANTITY DISCOUNTS CALCS
$orderqty = $info['quantity'];
if($orderqty > 1({
$qtydiscountvalue = $orderqty - 1; $discountcomment = 'Receive a \$1.50 discount per additional item added to your purchase.';
}else{
$qtydiscountvalue = 0; $discountcomment = 'Purchase another item and receive a \$1.50 discount per additional item.';
}
$qtydiscount = 1.50 * $qtydiscountvalue;

//echo both $qtydiscount and $discountcomment

///END QUANTITY DISCOUNTS CALCS

to more or less figure out the logic. There may be a cleaner way. smile Question now is how to apply it so the customer sees it. Preferably, it show up in the Shopping Cart so that when they see the discount it might encourage them to buy more.

Offline

 

#2 02-10-2017 09:02:59

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: how to apply discount on qty purchase at the shopping cart

This is a custom sale, so add it as a Custom Sale script under Store / Commerce / Custom Sale Methods, and activate it under Store / Component / Settings / Checkout, update Custom Sale Method and Custom Sale Method Status.  This will get it actually working in checkout.  In order to get the quantity of items in the cart:

Code:

$cartids = $this->globals('ecom.checkout_cartids');

$count = 0; foreach ($cartids as $cartid => $item) {$count = $count + $item['quantity'];}

You could add this type of code inline, but looking at the $cart in {private}/apps/ecom/ECOM/includes/cartdisplay.php if you want to add it to the shopping cart page too.


Nick Hendler

Offline

 

#3 02-10-2017 11:09:15

CrownRoyal
Member
Registered: 01-10-2009
Posts: 716

Re: how to apply discount on qty purchase at the shopping cart

Thanks Nick. Further to that idea, is it possible to limit the application of that script to just our own product line, and not the products we drop ship for other vendors?

Offline

 

#4 02-13-2017 09:59:26

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: how to apply discount on qty purchase at the shopping cart

Yes.  You're going to want to loop through $cartids and extract the data.  Here' a hint.  Do this:

Code:

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

To see what's in that array and what you have to work with.  If I recall, you want the 'sinshipinfo' key.


Nick Hendler

Offline

 

#5 02-13-2017 10:20:09

CrownRoyal
Member
Registered: 01-10-2009
Posts: 716

Re: how to apply discount on qty purchase at the shopping cart

Im not that technically competent. sad

Offline

 

#6 02-14-2017 10:21:47

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: how to apply discount on qty purchase at the shopping cart

Don't sell yourself short.  You're just iterating over a PHP array.


Nick Hendler

Offline

 

Board footer