Author Topic: Disable shopper group discount if normal discount applied  (Read 2698 times)

Piszi

  • Jr. Member
  • **
  • Posts: 58
Disable shopper group discount if normal discount applied
« on: May 02, 2011, 20:26:01 pm »
Hello,

I modified the ps_product.php's "getPriceByShopperGroup" function becouse I want to disable shopper group discount on those products which has normal discount applied.

So, what i did is really simple but i don't know if it could cause any errors in other functions.
oh I have only two groups 1. default(no discount) and 2. registred(10% discount), this hack may not work with more groups.

this is the code:
Code: [Select]
$disc_info = $this->get_discount( $product_id );

if (!empty($auth["shopper_group_discount"]) && $disc_info["amount"] > 0) {
  $price_info["product_price"]= $db->f("product_price");
}
else {
  $price_info["product_price"]= $db->f("product_price") * ((100 - $auth["shopper_group_discount"])/100);
}

and the original code was this:
(about line 1734 depends on VM version)
Code: [Select]
$price_info["product_price"]= $db->f("product_price") * ((100 - $auth["shopper_group_discount"])/100);
so far seems to be worging but as mentioned earlier I don't know whether is this stable.

If somebody who has more experince on VM than me, could test my hack for possible errors, I would be grateful

Thx

Reincha

  • Jr. Member
  • **
  • Posts: 137
Re: Disable shopper group discount if normal discount applied
« Reply #1 on: July 29, 2011, 13:34:03 pm »
Hi!

Thanks for your code ! I think this will solve my problem, but i have to make a few changes. it looks like you are good with code so maybe you can help:
Is it possible for this code to first check who has greater discount and then apply it. like if product discount is greater than shopper's choose product's, but if shopper has asigned greater discount, then use shoppers discount.

hope you can help!


p.s. does anyone know how can i show prices discount amount , new and old price to all products after shopper with discount is logged in?
for now its only 1 - already discounted price with no info on savings.

Thanks!

Piszi

  • Jr. Member
  • **
  • Posts: 58
Re: Disable shopper group discount if normal discount applied
« Reply #2 on: November 06, 2011, 18:34:50 pm »
p.s. does anyone know how can i show prices discount amount , new and old price to all products after shopper with discount is logged in?
for now its only 1 - already discounted price with no info on savings.

Isn't this inbuilt in VM?

for your other question you can do it like this
BUT YOU HAVE TO KNOW THAT THIS WILL ONLY WORK IF YOU HAVE ONLY ONE DISCOUNT TYPE!!! ONLY VALUE OR ONLY PERCENT!
Becouse you can not compare value to percent.
Code: [Select]
$disc_info = $this->get_discount( $product_id );

if (!empty($auth["shopper_group_discount"]) > $disc_info["amount"]) {
 
  $price_info["product_price"]= $db->f("product_price") * ((100 - $auth["shopper_group_discount"])/100);
}
else {
  $price_info["product_price"]= $db->f("product_price");
}