Zen Cart Logo
Forums / Setting Up Specials and SaleMaker / 15% Sale for all orders over £50 on specified category

15% Sale for all orders over £50 on specified category

Views: 4,724

Results 1 to 20 of 22
9 Apr 2016, 9:16 AM
#1
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

15% Sale for all orders over £50 on specified category

I have Quantity Discounts installed on a website.

It is used to offer 10% Discount over the whole site for orders over £150.

However I need to set up a special offer which offers 15% discount for all orders over £50 from 'category X'.

If ordering under £50 from category X then 10% should be applied as normal if the cart adds up to £150 when in a combination with other products.

If ordering over £50 from category X then 15% should be applied to the products from category X.

Really what I need to do is disable quantity discounts on category X and make the offer of 15% off for all orders over £50...or find some other method.

How would I do this?

I've thought about duplicating the quantity discounts module, which I think would achieve the above but I am not sure what the process would be in order to duplicate the module.

14 Apr 2016, 10:30 PM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: 15% Sale for all orders over £50 on specified category

There is a way to do this within the current code....

I am hoping that Ajeh will happen along to assist....

15 Apr 2016, 7:45 AM
#3
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: 15% Sale for all orders over £50 on specified category

Thanks for replying Kobra, I'm hoping Ajeh can assist.

15 Apr 2016, 8:09 AM
#4
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: 15% Sale for all orders over £50 on specified category

Just an update:

'If ordering over £50 from category X then 15% should be applied to the products from category X.'

So just to make it clear, the normal '10% off £150' would be disabled if someone order over £50 from category X - so they only get 15% off and not 25% off.

15 Apr 2016, 10:08 AM
#5
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: 15% Sale for all orders over £50 on specified category

What about if someone orders 200 with 100 of that being in category X? Do they get the 10% off of the other 100 or only the 15% off of the first? Ie. Can multiple discounts be applied at all?

15 Apr 2016, 10:15 AM
#6
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: 15% Sale for all orders over £50 on specified category

Or if a purchase of 300 is made, with 100 from category X (savings of 15 available) and the remaining 200 at 10% (savings of 20) would this be allowed, is the customer to be offered a direct choice, or through proper fine print advised to make two separate purchases (possibly incurring increased shipping prices)?

15 Apr 2016, 10:18 AM
#7
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: 15% Sale for all orders over £50 on specified category

They get 10% off the 100 say from categories 'A, B, and C' and 15% off 100 from category X

So the calculation would be 15% Discount for all products in category X - it would not carry over the 15% to other products

All other categories would apply 10% off for all orders over £150 as normal

It would then add together the products in the cart like this:

Category X products: 15% off

All other category products that add up to £150: 10% off

Does that make sense?

15 Apr 2016, 11:26 AM
#8
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: 15% Sale for all orders over £50 on specified category

Yup, wasn't as clear before, but is now! :)

That should definitely help in identifying a solution.

Not so sure that there is a built in method of applying the discount in that situation, because it does get a little more "complicated" in that scenario of applying multiple discounts to a single cart.

15 Apr 2016, 11:36 AM
#9
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: 15% Sale for all orders over £50 on specified category

Yes I realise it gets 'a little' more complicated :-) hence why I am asking for help!

This is nothing to do with this post but if you can't help with this one, would you mind taking a look at my post here regarding stripping html tags.

https://www.zen-cart.com/showthread.php?219976-Strip-HTML-and-WORD-formatting&p=1308604#post1308604

15 Apr 2016, 2:51 PM
#10
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: 15% Sale for all orders over £50 on specified category

If I understand what you are trying to do, then you appear to want to add another 5% to Category X products if over 50.00 ...

Eidt the file:
/includes/classes/shopping_cart.php

and add the code in RED to the bottom of the file:

[B]  function in_cart_product_total_price_category($category_id) {
    $products = $this->get_products();
//echo '<pre>'; echo print_r($products); echo '</pre>';
    for ($i=0, $n=sizeof($products); $i<$n; $i++) {
      $productsName = $products[$i]['name'];
      $ppe = $products[$i]['final_price'];
      $ppt = $ppe * $products[$i]['quantity'];
      $productsPriceEach = $ppe + $products[$i]['onetime_charges'];
      $productsPriceTotal = $ppt + $products[$i]['onetime_charges'];
      if ($products[$i]['category'] == $category_id) {
        $in_cart_product_price += $productsPriceTotal;
      }
    } // end FOR loop
    return $in_cart_product_price;
  }
[/B]
}

NOTE: that is added just before the existing closing bracket ...

Then, add the code in RED to the file:
/includes/modules/order_total/ot_coupon.php

    $od_amount = array('tax'=>0, 'total'=>0);

[B]global $discount_coupon;
$dc_check = $discount_coupon->fields['coupon_code'];
// bof: coupon add 5% to 1 category if over 50.00
if ($dc_check == '10OFFALL') {
  $cat_id = 10;
  $chk_disc = 0.00;
  $chk_amount = $_SESSION['cart']->in_cart_product_total_price_category($cat_id);
  if ($chk_amount >= 50.00) {
    $chk_disc = $chk_amount * .05;
  }
}
// bof: coupon add 5% to 1 category if over 50.00
[/B]
    if ($_SESSION['cc_id'])

and a little further down:

            case 'P': // percentage
              $od_amount['total'] = zen_round($orderTotalDetails['orderTotal']*($coupon->fields['coupon_amount']/100)[B] + $chk_disc[/B], $currencyDecimalPlaces);
              $od_amount['type'] = $coupon->fields['coupon_type'];
              $ratio = $od_amount['total']/$orderTotalDetails['orderTotal'];
              break;
            case 'E': // percentage & Free Shipping
              $od_amount['total'] = zen_round($orderTotalDetails['orderTotal']*($coupon->fields['coupon_amount']/100)[B] + $chk_disc[/B], $currencyDecimalPlaces);
              $od_amount['type'] = $coupon->fields['coupon_type'];
              $ratio = $od_amount['total']/$orderTotalDetails['orderTotal'];
              // add in Free Shipping
              $od_amount['total'] = $od_amount['total'] + $orderTotalDetails['shipping'];
              $od_amount['tax'] = ($this->calculate_tax == 'Standard') ? $orderTotalDetails['shippingTax'] : 0;
              if (isset($_SESSION['shipping_tax_description']) && $_SESSION['shipping_tax_description'] != '') {
                $od_amount['tax_groups'][$_SESSION['shipping_tax_description']] = $od_amount['tax'];
              }
              break;

See if that does what you are trying to do ...

15 Apr 2016, 2:52 PM
#11
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: 15% Sale for all orders over £50 on specified category

NOTE: change the coupon code from 10OFFALL to you code and the $cat_id from 10 to your categories_id ...

15 Apr 2016, 3:08 PM
#12
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: 15% Sale for all orders over £50 on specified category

Thanks Linda, that would most likely do what I want. However is it possible without using a coupon code?

15 Apr 2016, 3:15 PM
#13
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: 15% Sale for all orders over £50 on specified category

Why do you want to do it without a specific coupon code?

Are you planning on ALL coupon codes to work this way?

15 Apr 2016, 3:22 PM
#14
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: 15% Sale for all orders over £50 on specified category

No, but ideally I would like to put the whole category on sale this way without a coupon code. Possibly through salemaker or specials so the customer doesn't have to enter a code. From time to time I will need to set up similar offers, but other times I will be straightforward (anything over £0 rather than anything over £50)

15 Apr 2016, 3:34 PM
#15
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: 15% Sale for all orders over £50 on specified category

You could make this work for all coupon codes with:

if ([B]true || [/B]$dc_check == '10OFFALL') {

and should you need it for a specific coupon code just remove the:
true ||

so that you have that in their for easy reference ...

15 Apr 2016, 3:46 PM
#16
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: 15% Sale for all orders over £50 on specified category

Ok, does it have to be done this way with a coupon code?

15 Apr 2016, 3:51 PM
#17
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: 15% Sale for all orders over £50 on specified category

If you use the:

if (true || $dc_check == '10OFFALL') {

any coupon code will work ... you could even leave in the one I used ...

15 Apr 2016, 4:04 PM
#18
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: 15% Sale for all orders over £50 on specified category

Ok are you saying its a coupon, but to the customer doesn't have to enter a code at the checkout? In this case it would be '10OFFALL'

15 Apr 2016, 4:26 PM
#19
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: 15% Sale for all orders over £50 on specified category

This only works if a coupon is used and follows the settings on the coupon ... without a coupon it never runs ...

Are you trying to do this without a Coupon at all? :lookaroun

15 Apr 2016, 5:04 PM
#20
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: 15% Sale for all orders over £50 on specified category

Yes I am trying to do it without a coupon.