Jump to content


Corporate Sponsors


Latest News: (loading..)

* * * * * 1 votes

Get 1 Free


345 replies to this topic

#241 pepe4567

  • Community Member
  • 10 posts
  • Real Name:Cesar

Posted 06 March 2009, 16:20

View Postzumn, on Feb 27 2009, 06:50 AM, said:

Hello.

Get 1 Free is terrific. I was just wondering if it could be modified to offer say, 1 free book (any title) if the customer bought 5 books (each of any title).

Thanks for any help you can offer!

Please, anyone is working on this?

I think it's so important: We must can give the free product but buying many productos from categories and not only in the same product.

(My php is not so good...)

Greetings!!!

#242 kymation

  • Community Sponsor
  • 5,658 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 07 March 2009, 05:41

It could be done, but it wouldn't be easy. This contribution to give a quantity of a specific product when the customer purchased a quantity of another specific product. It doesn't recognize purchases of multiple different products. You might want to check through the contributions to see if there is something closer to what you want.

Regards
Jim
My Addons

Banners Box 2.3.1 Support
Categories Accordion Box 2.3.1 Support
Categories Images Box 2.2x 2.3.1 Support
Closest Shipper 2.2x Support
Document Manager 2.2x Support
Generic Box 2.3.1 Support
Get 1 Free 2.2x Support
Include HTML and Text Boxes 2.2x
jQuery Banner Rotator 2.2x 2.3.1 Support
Modular Front Page 2.3.1 Support
Modular SEO Header Tags 2.3.1 Support
More Pics 2.2x Support
MVS 2.2x Support
osC Catalog 2.2x Support
PDF Datasheet 2.3.1 Support
Price Updater 2.2x
Products Specifications 2.2x 2.3.1 Development Version Support Bugs/Suggestions
Request a Review 2.2x - 2.3.1 Support
Similar Products Box 2.2x
Theme Switcher 2.3.1 Support

#243 steve_s

  • Community Member
  • 1,580 posts
  • Real Name:steve
  • Gender:Male
  • Location:London

Posted 19 March 2009, 20:52

Hi

I've added margin report http://addons.oscommerce.com/info/1594 it added an extra field products_cost in products and orders table,
when i goto checkout_process.php i get this error
1366 - Incorrect decimal value: '' for column 'products_cost' at row 1

insert into orders_products (orders_id, products_id, products_model, products_name, products_price, final_price, products_cost, products_tax, products_quantity) values ('33', '42', '', 'Viking 256 MB Secure Digital Flash Card', '0', '0', '', '0', '1')

i have tried adding in checkout_process.php the following in get 1 free area
'products_cost ="0"', or
'products_cost' => 0,

but i still get the same error any idea how to get rid of it would like to use actuall cost price from products table but happy with a zero for products_cost

Thanks Steve

Edited by steve_s, 19 March 2009, 20:53.


#244 kymation

  • Community Sponsor
  • 5,658 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 20 March 2009, 02:41

You would need to retrieve that cost from wherever the other contribution stores it and add it to the free product. I'm not familiar with that contribution so I can't tell you where to find the data.

Regards
Jim
My Addons

Banners Box 2.3.1 Support
Categories Accordion Box 2.3.1 Support
Categories Images Box 2.2x 2.3.1 Support
Closest Shipper 2.2x Support
Document Manager 2.2x Support
Generic Box 2.3.1 Support
Get 1 Free 2.2x Support
Include HTML and Text Boxes 2.2x
jQuery Banner Rotator 2.2x 2.3.1 Support
Modular Front Page 2.3.1 Support
Modular SEO Header Tags 2.3.1 Support
More Pics 2.2x Support
MVS 2.2x Support
osC Catalog 2.2x Support
PDF Datasheet 2.3.1 Support
Price Updater 2.2x
Products Specifications 2.2x 2.3.1 Development Version Support Bugs/Suggestions
Request a Review 2.2x - 2.3.1 Support
Similar Products Box 2.2x
Theme Switcher 2.3.1 Support

#245 steve_s

  • Community Member
  • 1,580 posts
  • Real Name:steve
  • Gender:Male
  • Location:London

Posted 20 March 2009, 20:16

View Postkymation, on Mar 20 2009, 02:41 AM, said:

You would need to retrieve that cost from wherever the other contribution stores it and add it to the free product. I'm not familiar with that contribution so I can't tell you where to find the data.

Regards
Jim

Thanks Jim,

I shall do some hunting was hoping there might be a simple way to get rid of error, rest assured when i've found out i shall post solution here for others

Steve

Edited by steve_s, 20 March 2009, 20:16.


#246 ssnb

  • Community Member
  • 278 posts
  • Real Name:Sol
  • Gender:Male
  • Location:Auckland, New Zealand

Posted 25 March 2009, 03:03

Hi Jim

Thanks for this great contribution

Any chance of a next version to allow you to specify buy one of these, choose any of these (so in admin you can hold down CNTRL and select all the items they can choose from!?

Thanks
Sol

#247 kymation

  • Community Sponsor
  • 5,658 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 25 March 2009, 03:09

I'll add it to my wish list, but don't hold your breath. I have a long waiting list of features and new addons I'd like to code up.

Regards
Jim
My Addons

Banners Box 2.3.1 Support
Categories Accordion Box 2.3.1 Support
Categories Images Box 2.2x 2.3.1 Support
Closest Shipper 2.2x Support
Document Manager 2.2x Support
Generic Box 2.3.1 Support
Get 1 Free 2.2x Support
Include HTML and Text Boxes 2.2x
jQuery Banner Rotator 2.2x 2.3.1 Support
Modular Front Page 2.3.1 Support
Modular SEO Header Tags 2.3.1 Support
More Pics 2.2x Support
MVS 2.2x Support
osC Catalog 2.2x Support
PDF Datasheet 2.3.1 Support
Price Updater 2.2x
Products Specifications 2.2x 2.3.1 Development Version Support Bugs/Suggestions
Request a Review 2.2x - 2.3.1 Support
Similar Products Box 2.2x
Theme Switcher 2.3.1 Support

#248 fischo

  • Community Member
  • 9 posts
  • Real Name:Jozef Fischer

Posted 08 April 2009, 05:50

Hello,

I have installed your contribution and there is any bug:

when I set:
Quantity to Qualify: 2
Quantity of Free Product: 4
(I set it to this product: http://www.fitpro.sk/product_info.php?products_id=352)

When I put 2 products into cart, it gives me only 1 free product (instead of 4).

Could anybody help me, please ? Thanks a million! :)

#249 kymation

  • Community Sponsor
  • 5,658 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 08 April 2009, 16:53

This works as expected in my test shop, so you have an error somewhere in your installation. Check your modifications carefully.

Regards
Jim
My Addons

Banners Box 2.3.1 Support
Categories Accordion Box 2.3.1 Support
Categories Images Box 2.2x 2.3.1 Support
Closest Shipper 2.2x Support
Document Manager 2.2x Support
Generic Box 2.3.1 Support
Get 1 Free 2.2x Support
Include HTML and Text Boxes 2.2x
jQuery Banner Rotator 2.2x 2.3.1 Support
Modular Front Page 2.3.1 Support
Modular SEO Header Tags 2.3.1 Support
More Pics 2.2x Support
MVS 2.2x Support
osC Catalog 2.2x Support
PDF Datasheet 2.3.1 Support
Price Updater 2.2x
Products Specifications 2.2x 2.3.1 Development Version Support Bugs/Suggestions
Request a Review 2.2x - 2.3.1 Support
Similar Products Box 2.2x
Theme Switcher 2.3.1 Support

#250 fischo

  • Community Member
  • 9 posts
  • Real Name:Jozef Fischer

Posted 08 April 2009, 17:47

do you have any tip where I should find that error?
Thanks.

#251 kymation

  • Community Sponsor
  • 5,658 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 08 April 2009, 22:35

I didn't think it was possible. Did you set the limit to 1?

Regards
Jim
My Addons

Banners Box 2.3.1 Support
Categories Accordion Box 2.3.1 Support
Categories Images Box 2.2x 2.3.1 Support
Closest Shipper 2.2x Support
Document Manager 2.2x Support
Generic Box 2.3.1 Support
Get 1 Free 2.2x Support
Include HTML and Text Boxes 2.2x
jQuery Banner Rotator 2.2x 2.3.1 Support
Modular Front Page 2.3.1 Support
Modular SEO Header Tags 2.3.1 Support
More Pics 2.2x Support
MVS 2.2x Support
osC Catalog 2.2x Support
PDF Datasheet 2.3.1 Support
Price Updater 2.2x
Products Specifications 2.2x 2.3.1 Development Version Support Bugs/Suggestions
Request a Review 2.2x - 2.3.1 Support
Similar Products Box 2.2x
Theme Switcher 2.3.1 Support

#252 fischo

  • Community Member
  • 9 posts
  • Real Name:Jozef Fischer

Posted 10 April 2009, 09:03

I have set "Maximum Free Products: " to 10...

#253 steve_s

  • Community Member
  • 1,580 posts
  • Real Name:steve
  • Gender:Male
  • Location:London

Posted 10 April 2009, 16:03

View Poststeve_s, on Mar 20 2009, 09:16 PM, said:

Thanks Jim,

I shall do some hunting was hoping there might be a simple way to get rid of error, rest assured when i've found out i shall post solution here for others

Steve

Hi Again Jim,

Im almost there with integrating Profit margin and Get 1 Free, no sql errors now, but is putting product_cost in order_products table as 0,

Not sure if i am calling the Get 1 free product id correctly, code below would appreciate if you could take a quick look, product_cost is in products table

Bold is lines ive added

// Get 1 free
// If this product qualifies for free product(s) add the free products
if (is_array ($free_product = $cart->get1free ($products_id))) {
// Update products_ordered (for bestsellers list)
// comment out the next line if you don't want free products in the bestseller list
tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $free_product['quantity']) . " where products_id = '" . tep_get_prid($free_product['id']) . "'");

$product_cost_query = tep_db_query("select products_cost from " . TABLE_PRODUCTS . " where products_id ='". tep_get_prid($free_product['id']). "'");
$product_cost = tep_db_fetch_array($product_cost_query);


$sql_data_array = array('orders_id' => $insert_id,
'products_id' => $free_product['id'],
'products_model' => $free_product['model'],
'products_name' => $free_product['name'],
'products_price' => 0,
'products_cost' => $product_cost['products_cost'],
'final_price' => 0,
'products_tax' => '',
'products_quantity' => $free_product['quantity']
);
tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);

$total_weight += ($free_product['quantity'] * $free_product['weight']);
}
// end Get 1 free

Thanks
Steve

Edited by steve_s, 10 April 2009, 16:05.


#254 kymation

  • Community Sponsor
  • 5,658 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 10 April 2009, 16:28

The tep_get_prid() function is unnecessary, since you already have the products ID. Try:
$product_cost_query = tep_db_query("select products_cost from " . TABLE_PRODUCTS . " where products_id ='". (int) $free_product['id'] . "'";
$product_cost = tep_db_fetch_array($product_cost_query);
That may be a bug in the current code.

Regards
Jim
My Addons

Banners Box 2.3.1 Support
Categories Accordion Box 2.3.1 Support
Categories Images Box 2.2x 2.3.1 Support
Closest Shipper 2.2x Support
Document Manager 2.2x Support
Generic Box 2.3.1 Support
Get 1 Free 2.2x Support
Include HTML and Text Boxes 2.2x
jQuery Banner Rotator 2.2x 2.3.1 Support
Modular Front Page 2.3.1 Support
Modular SEO Header Tags 2.3.1 Support
More Pics 2.2x Support
MVS 2.2x Support
osC Catalog 2.2x Support
PDF Datasheet 2.3.1 Support
Price Updater 2.2x
Products Specifications 2.2x 2.3.1 Development Version Support Bugs/Suggestions
Request a Review 2.2x - 2.3.1 Support
Similar Products Box 2.2x
Theme Switcher 2.3.1 Support

#255 fischo

  • Community Member
  • 9 posts
  • Real Name:Jozef Fischer

Posted 10 April 2009, 20:32

View Postfischo, on Apr 8 2009, 07:50 AM, said:

Hello,

I have installed your contribution and there is any bug:

when I set:
Quantity to Qualify: 2
Quantity of Free Product: 4
(I set it to this product: http://www.fitpro.sk/product_info.php?products_id=352)

When I put 2 products into cart, it gives me only 1 free product (instead of 4).

Could anybody help me, please ? Thanks a million! :)


FINALLY I FOUND THAT BUG! And It was not my error in installation!!!

in the file catalog/includes/classes/shopping_cart.php
at the end of this file - in the function function get1free ($products_id)

there was a line with this code:
$free_quantity = floor ($products_quantity / $get_1_free['products_qualify_quantity']);


I changed it to:
$free_quantity = floor ($products_quantity / $get_1_free['products_qualify_quantity']) * $get_1_free['products_free_quantity'];


BECAUSE:
when I set:
Quantity to Qualify: 2 X
Quantity of Free Product: 4 (Product B)
Maximum Free Items: 100

(Product A) A=2
B would be 4...

old code: floor(A/X) is floor(2/2) is 1

NEW CODE: floor(A/X)*B is floor(2/2)*4 is 4

#256 kymation

  • Community Sponsor
  • 5,658 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 10 April 2009, 20:46

That's Line 470 in the current release. Your code is unnecessary, since the quantity of free items per product is calculated in Line 489:
							  'quantity' => $free_quantity * $get_1_free['products_free_quantity'],
Your change will duplicate the quantity multiplication. It also interferes with the maximum calculation in Lines 471-473.

Regards
Jim
My Addons

Banners Box 2.3.1 Support
Categories Accordion Box 2.3.1 Support
Categories Images Box 2.2x 2.3.1 Support
Closest Shipper 2.2x Support
Document Manager 2.2x Support
Generic Box 2.3.1 Support
Get 1 Free 2.2x Support
Include HTML and Text Boxes 2.2x
jQuery Banner Rotator 2.2x 2.3.1 Support
Modular Front Page 2.3.1 Support
Modular SEO Header Tags 2.3.1 Support
More Pics 2.2x Support
MVS 2.2x Support
osC Catalog 2.2x Support
PDF Datasheet 2.3.1 Support
Price Updater 2.2x
Products Specifications 2.2x 2.3.1 Development Version Support Bugs/Suggestions
Request a Review 2.2x - 2.3.1 Support
Similar Products Box 2.2x
Theme Switcher 2.3.1 Support

#257 steve_s

  • Community Member
  • 1,580 posts
  • Real Name:steve
  • Gender:Male
  • Location:London

Posted 10 April 2009, 23:11

View Postkymation, on Apr 10 2009, 05:28 PM, said:

The tep_get_prid() function is unnecessary, since you already have the products ID. Try:
$product_cost_query = tep_db_query("select products_cost from " . TABLE_PRODUCTS . " where products_id ='". (int) $free_product['id'] . "'";
$product_cost = tep_db_fetch_array($product_cost_query);
That may be a bug in the current code.

Regards
Jim

Hi Jim,

Thanks i'm still getting zero for some reason think i might have to leave as that for now, at least no errors on order at checkout

Steve

#258 kymation

  • Community Sponsor
  • 5,658 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 11 April 2009, 01:49

Add
print $free_product['id'];
at that point to see if the variable is being set. If not, track it back to the database query that should have set it.

Regards
Jim
My Addons

Banners Box 2.3.1 Support
Categories Accordion Box 2.3.1 Support
Categories Images Box 2.2x 2.3.1 Support
Closest Shipper 2.2x Support
Document Manager 2.2x Support
Generic Box 2.3.1 Support
Get 1 Free 2.2x Support
Include HTML and Text Boxes 2.2x
jQuery Banner Rotator 2.2x 2.3.1 Support
Modular Front Page 2.3.1 Support
Modular SEO Header Tags 2.3.1 Support
More Pics 2.2x Support
MVS 2.2x Support
osC Catalog 2.2x Support
PDF Datasheet 2.3.1 Support
Price Updater 2.2x
Products Specifications 2.2x 2.3.1 Development Version Support Bugs/Suggestions
Request a Review 2.2x - 2.3.1 Support
Similar Products Box 2.2x
Theme Switcher 2.3.1 Support

#259 steve_s

  • Community Member
  • 1,580 posts
  • Real Name:steve
  • Gender:Male
  • Location:London

Posted 11 April 2009, 12:37

View Postkymation, on Apr 11 2009, 02:49 AM, said:

Add
print $free_product['id'];
at that point to see if the variable is being set. If not, track it back to the database query that should have set it.

Regards
Jim

Yep i had to ammend the query slightly tested on phpmyadmin got 0 rows back so added products_id, but doesnt seem to recognise $free_product_id
$product_cost_query = tep_db_query("select products_id, products_cost  from " . TABLE_PRODUCTS . " where products_id ='". (int)$free_product['id']. "'");
$product_cost = tep_db_fetch_array($product_cost_query);

such a smiple thing bieng made hard :rolleyes: I even tried $cart->get1free ($products_id) in sql query

Thanks for all the help you gave Jim much appreciated

Edited by steve_s, 11 April 2009, 12:38.


#260 fischo

  • Community Member
  • 9 posts
  • Real Name:Jozef Fischer

Posted 11 April 2009, 14:32

View Postkymation, on Apr 10 2009, 10:46 PM, said:

That's Line 470 in the current release. Your code is unnecessary, since the quantity of free items per product is calculated in Line 489:
							  'quantity' => $free_quantity * $get_1_free['products_free_quantity'],
Your change will duplicate the quantity multiplication. It also interferes with the maximum calculation in Lines 471-473.

Regards
Jim

.... hm, I have downloaded Version 1.4.2... there is line 489 like this:
							  'quantity' => $free_quantity,

If we multiply 'quantity' => $free_quantity * $get_1_free['products_free_quantity'], than we can get more than maximum allowed free items per one shopping cart....