Jump to content
Latest News: (loading..)

Recommended Posts

@@Tsimi @@raiwa

 

confused.png ...at two different products counted correctly, but two same products not!??

 

 

your setting is show prices with tax = false and apply tax to shipping and order subtotal discount = 10%?

 

Yes!

 

rgds

phatman

Edited by phatman

Share this post


Link to post
Share on other sites

@@phatman,

 

You are right.

 

Please try this mod and confirm (only line 124 changed):

                    	//here it gets complicate, we have to find the proportional part of the global discount for each product
                      $global_tax_correction = $this->format_raw($order->products[$i]['qty']*(($order->products[$i]['price']/$order->info['subtotal'])*$discount)+(($order->products[$i]['qty']*$order->products[$i]['price']/$order->info['subtotal'])*$discount) * ($order->products[$i]['tax'] / 100));
                      $order->info['total'] -= $global_tax_correction;

Nuts, we forgot to multiply with the products quantity, sorry.

 

 

Thank You!

Edited by raiwa

Share this post


Link to post
Share on other sites

New version 3.4 uploaded.

 

http://addons.oscommerce.com/info/9460

 

Thanks again raiwa for the quick fix. :thumbsup:

 

@@raiwa

 

Added you to the addon maintainer list since you do more and better troubleshooting.

Edited by Tsimi

When you ask for help/support:

  • Always state your osCommerce version
  • If possible, list up installed add-ons
  • 3rd party templates are not supported in the forum

Latest osC: osCommerce CE (Community Edition aka. v2.3.4.1 Frozen)

 

Share this post


Link to post
Share on other sites

@Tsimi

 

I want to know is it for edge or also for gold??? because the old one 3.2 is doing great and now I have update the new 3.4 and now when I get the settings like the image it will not work.

 

 

post-336856-0-34380700-1460055813_thumb.jpg

post-336856-0-72663700-1460055817_thumb.jpg

post-336856-0-83360500-1460055820_thumb.jpg

Share this post


Link to post
Share on other sites

@@dinopacha

 

That is strange because the only file that has been updated and changed is the order total module file only.

If you refresh the page what happens?


When you ask for help/support:

  • Always state your osCommerce version
  • If possible, list up installed add-ons
  • 3rd party templates are not supported in the forum

Latest osC: osCommerce CE (Community Edition aka. v2.3.4.1 Frozen)

 

Share this post


Link to post
Share on other sites

@@dinopacha

 

Haha I didn't see the other images.

LOL I was just looking at the admin image.

 

Yeah I think hes right @@raiwa. I also have troubles to get a discount on products, categories or manufacturer.

Works fine on sub-total though. Weird I didn't had that on my office PC in the morning. :rolleyes:

Edited by Tsimi

When you ask for help/support:

  • Always state your osCommerce version
  • If possible, list up installed add-ons
  • 3rd party templates are not supported in the forum

Latest osC: osCommerce CE (Community Edition aka. v2.3.4.1 Frozen)

 

Share this post


Link to post
Share on other sites

@@Tsimi, @@dinopacha

 

 

@@dinopacha

 

Haha I didn't see the other images.

LOL I was just looking at the admin image.

 

Yeah I think hes right @@raiwa. I also have troubles to get a discount on products, categories or manufacturer.

Works fine on sub-total though. Weird I didn't had that on my office PC in the morning. :rolleyes:

 

I do not know what you do different. For me it works:

 

Edited by raiwa

Share this post


Link to post
Share on other sites

@@raiwa

 

Like I said at my office, the exact same module no problem. So something weird is going on here.

I will uninstall it and re-install it again.


When you ask for help/support:

  • Always state your osCommerce version
  • If possible, list up installed add-ons
  • 3rd party templates are not supported in the forum

Latest osC: osCommerce CE (Community Edition aka. v2.3.4.1 Frozen)

 

Share this post


Link to post
Share on other sites

@@Tsimi,
 

Like I said at my office, the exact same module no problem. So something weird is going on here.
I will uninstall it and re-install it again.

I installed  on a different test store and could recreate the problem. I hav no idea why it worked on the first store where I did all my tests.

 

I could fix it moveing one bracket in ot_discount.php in this section:

                    if (!empty($order->products[$i]['tax'])) {
                    	if (DISPLAY_PRICE_WITH_TAX != 'true') {
                    		$tax_correction = $this->format_raw(($products_discount * ($order->products[$i]['tax'] / 100)));
                    		$order->info['total'] -= $tax_correction;
                    	} else {
                    		$tax_correction = $this->format_raw($products_discount - $products_discount / (1.0 + $order->products[$i]['tax'] / 100));
                    	}
                    } // this bracket moved ***
                    $subtotal_correction += $order->products[$i]['price']; //use for tax calculation only products which have taxes
                    $order->info['tax'] -= $tax_correction;
                    $order->info['tax_groups'][$order->products[$i]['tax_description']] -= $tax_correction;
                    $discount += $products_discount;
                  } // from here ***
                }

I checked, please do a hardcore test too.

Edited by raiwa

Share this post


Link to post
Share on other sites

@@raiwa

 

Thanks Rainer. :pray:

Same here I swear at my office I had no issues with the latest version but here at home it won't work. Verflucht ist es!

I will test the (censored) out of it once I finish the product_listing module for the cart.

Without it I can't see the products to test further.

Edited by Tsimi

When you ask for help/support:

  • Always state your osCommerce version
  • If possible, list up installed add-ons
  • 3rd party templates are not supported in the forum

Latest osC: osCommerce CE (Community Edition aka. v2.3.4.1 Frozen)

 

Share this post


Link to post
Share on other sites

So I create at least 5-6 different types of discount codes with all kinds of conditions and all worked fine.

I will upload a new package to the addons area and I hope that this will work now for a while.

 

Thanks to raiwa for always coming up with a quick solution. All credits for the last 3 versions to him.

Edited by Tsimi

When you ask for help/support:

  • Always state your osCommerce version
  • If possible, list up installed add-ons
  • 3rd party templates are not supported in the forum

Latest osC: osCommerce CE (Community Edition aka. v2.3.4.1 Frozen)

 

Share this post


Link to post
Share on other sites

Discount Codes 3.5 BS uploaded

 

http://addons.oscommerce.com/info/9460


When you ask for help/support:

  • Always state your osCommerce version
  • If possible, list up installed add-ons
  • 3rd party templates are not supported in the forum

Latest osC: osCommerce CE (Community Edition aka. v2.3.4.1 Frozen)

 

Share this post


Link to post
Share on other sites

@@raiwa

 

You won't believe it. <_<

Another bug but I think I got the fix already. Can you confirm this if you find time in between.

Create a discount code for order totals only set it to what ever amount you like. It won't calculate the total.

 

within the order total code part around line 150 need to add the following

                  if (!empty($order_tax)) {
                    $order->info['tax'] = $order_tax;
                  }
                }
              }
	    $order->info['total'] -= $discount; // added this here
            }
          }
        }
      }
Edited by Tsimi

When you ask for help/support:

  • Always state your osCommerce version
  • If possible, list up installed add-ons
  • 3rd party templates are not supported in the forum

Latest osC: osCommerce CE (Community Edition aka. v2.3.4.1 Frozen)

 

Share this post


Link to post
Share on other sites

@@Tsimi,

 

I checked and for me it works correct.

Can you give me all setting details.

Please check if you have this part identical:

              } elseif (!empty($check['orders_total'])) {
                if ($check['orders_total'] == 2) {
                  $discount = (strpos($check['discount_values'], '%') === false ? $check['discount_values'] : $order->info['subtotal'] * str_replace('%', '', $check['discount_values']) / 100);
                  if ($discount > $order->info['subtotal']) {
                  	$discount = $order->info['subtotal'];
                  }
                	$order_tax = 0;
                	for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
                    if (!empty($order->products[$i]['tax'])) {
                    	//here it gets complicate, we have to find the proportional part of the global discount for each product
                      $global_tax_correction = $this->format_raw($order->products[$i]['qty']*(($order->products[$i]['price']/$order->info['subtotal'])*$discount)+(($order->products[$i]['qty']*$order->products[$i]['price']/$order->info['subtotal'])*$discount) * ($order->products[$i]['tax'] / 100));
                      $order->info['total'] -= $global_tax_correction;
                    }
                  }
                  
                  if (is_array($order->info['tax_groups']) && count($order->info['tax_groups']) > 0) {
                    foreach ($order->info['tax_groups'] as $key => $value) {
                      if (!empty($value)) {
                        $order->info['tax_groups'][$key] = $this->format_raw(($order->info['subtotal'] - $discount) * ($value / $order->info['subtotal']));
                        $order_tax += $order->info['tax_groups'][$key];
                      }
                    }
                  }
                  if (!empty($order_tax)) {
                    $order->info['tax'] = $order_tax;
                  }
                }
              }
            }
          }
        }
      }

      if (!empty($discount)) {

rgds

Rainer

Share this post


Link to post
Share on other sites

@@raiwa

 

I have that part. Exactly same code.

My test discount setting is

 

10% on order sub-total

Display prices with tax = false

shipping with tax on it

 

it works just fine with products/categories/manufacturers but not when using order sub-total.

 

Example:

 

Products

 

There's something about Mary 49.99

Blade Runner 30.00

 

Sub-Total: $79.99

Discount (111): -$8.00

Flat Rate (): $5.00

Total: $84.99 <- wrong total

 

when I add this code

$order->info['total'] -= $discount;

after

                  if (!empty($order_tax)) {
                    $order->info['tax'] = $order_tax;
                  }
                }

It works but I just want to make sure that that is the right solution or just another patch that opens a new issue.

Edited by Tsimi

When you ask for help/support:

  • Always state your osCommerce version
  • If possible, list up installed add-ons
  • 3rd party templates are not supported in the forum

Latest osC: osCommerce CE (Community Edition aka. v2.3.4.1 Frozen)

 

Share this post


Link to post
Share on other sites

@Tsimi @raiwa

 

​I have put the codes above in it an everything works ok, but the discount codes works only at 1 product so if you got 2 items of 50 dollar a piece with 50% discount it will give me 25 dollars discount. and it has to be 50 dollar. :mellow:

Edited by dinopacha

Share this post


Link to post
Share on other sites

@@Tsimi,

 

Could repeat it now. Your example is without tax, my test was with tax.

I checked now and your fix works for your setting (without tax) but breaks my setting with tax.

I found the following solution and it works for bot, with and without tax:

                  if (is_array($order->info['tax_groups']) && count($order->info['tax_groups']) > 0) {
                    foreach ($order->info['tax_groups'] as $key => $value) {
                      if (!empty($value)) {
                        $order->info['tax_groups'][$key] = $this->format_raw(($order->info['subtotal'] - $discount) * ($value / $order->info['subtotal']));
                        $order_tax += $order->info['tax_groups'][$key];
                      }
                    }
                  }
                  if (!empty($order_tax)) {
                    $order->info['tax'] = $order_tax;
                  } else {
                  	$order->info['total'] -= $discount;
                  }
                }
              }
            }
          }
        }
      }

I checked with different order subtotal settings, different tax rates and zone and it works for me for all.

Please do some more hardcore test before uploading to get rid off the bad course :-

 

rgds

Rainer

Share this post


Link to post
Share on other sites

@@raiwa

 

Thanks. Yeah that seems to do the trick.....for now. I will wait with uploading a new version because I went from ver. 3.3 to 3.5 in no time patching one thing after the other. This time I'll wait for more people to test this.

Your solution is here in this thread so if people have trouble using the addon they should come here to look.

As soon 1-2 other shop owners or devs can confirm this fix I'll upload a new version 3.6.

 

Thanks again. :thumbsup:


When you ask for help/support:

  • Always state your osCommerce version
  • If possible, list up installed add-ons
  • 3rd party templates are not supported in the forum

Latest osC: osCommerce CE (Community Edition aka. v2.3.4.1 Frozen)

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×