Jump to content
swguy

[Contribution] Better Together Discounting Module

Recommended Posts

If you want you can change the code to replace the old table defines with the hardcoded names,  but it will be faster just to use the patch I just posted. 


Contributions: Better Together and Quantity Discounts for osCommerce 2.3.x and Phoenix. See my profile for more details.

Share this post


Link to post
Share on other sites
On 7/31/2019 at 11:05 PM, swguy said:

Adding back the defines will fix the issue. 

In includes/modules/order_total/ot_better_together.php after php starts, add: 

if (!defined('TABLE_PRODUCTS')) {
  define('TABLE_PRODUCTS', 'products');
}
if (!defined('TABLE_PRODUCTS_TO_CATEGORIES')) {
  define('TABLE_PRODUCTS_TO_CATEGORIES', 'products_to_categories');
}
if (!defined('TABLE_TAX_RATES')) {
  define('TABLE_TAX_RATES', 'tax_rates');
}

Yeah this fixed it

Share this post


Link to post
Share on other sites

The usual way to fix this is to just use the table names in your queries....ie replace TABLE_TAX_RATES with tax_rates....problem solved.

Dan

Share this post


Link to post
Share on other sites

Agreed - I'm just getting all the required changes sorted and then I'll submit an update. 


Contributions: Better Together and Quantity Discounts for osCommerce 2.3.x and Phoenix. See my profile for more details.

Share this post


Link to post
Share on other sites

Installed and playing with the contribution - 2.3.4.1 CE Edge and PHP 7.0

This is what I'm testing:

$this->add_cat_to_cat(3,3,"%", 100);

Which essentially means - buy one from category 3, get one from category 3 for free (100% off)

If I put 10 items in my cart from category 3....5 of them are being discounted 100% and given for free.

Buy One, Get One Free...over and over and over

Is there a way to limit this to only one free item per cart? 

Sorry if this has been answered already.  I rushed thru this thread and didn't see anything.

- Andrea

Share this post


Link to post
Share on other sites

Nothing is built in.  But if you look at includes/modules/order_total/ot_better_together.php around line 310 where it says

       for ($i=0, $n=sizeof($discountable_products); $i<$n; $i++) {
you could do a check like: 

if ($discount > 0) break; 

 

 

 


Contributions: Better Together and Quantity Discounts for osCommerce 2.3.x and Phoenix. See my profile for more details.

Share this post


Link to post
Share on other sites

@swguy Dear Scott,

I have been playing with this wonderful app of yours for some time. Yesterday, I saw a FAQ on your website:

Quote

Q: What would my setup() look like if I wanted to do buy one of item 5, get one from category 2, 7 or 9 at $5 off?
A: Here's what you would do:


  function setup() { 
      $this->add_prod_to_cat(5,2,"$", 5); 
      $this->add_prod_to_cat(5,7,"$", 5); 
      $this->add_prod_to_cat(5,9,"$", 5); 
  }

So, I tried a similar promo and tested it. To my surprise, the promo will calculate $5 discount only, no matter items of one,  two or all three categories 2, 7 and 9 are included in checkout. It seems the discount only apply to the first pair of better together promo and ignore the others. Is the algorithm meant to work this way?

 

Share this post


Link to post
Share on other sites

Yes it is. Better Together deals with pairs of items. Get ONE from ONE of these categories (2 OR 7 OR 9). 

If you need "get multiple from any of these categories" look at Big Chooser.


Contributions: Better Together and Quantity Discounts for osCommerce 2.3.x and Phoenix. See my profile for more details.

Share this post


Link to post
Share on other sites

I just realized I could change the function get_discount( ) in ot_better_together.php to enable totalling the discounted amount of all the three items in categories 2 & 7 & 9. 😄

 

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

×