Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Get 1 Free


kymation

Recommended Posts

Hello Martin,

 

Thanks!! for your Suggestions. as Above Add-on give Discount on order Total Level.

I want to Display the Discount on Products level As well.

 

For Ex:

If i have 3 products In Cart with Qty 1 for Each.

Product 2 Have least Price from Other 2 products.

Then i want , products 2 price Will be Shown as 0 and Other Stays the Same.

And other Cart Calculations As per the Above Products Price.

 

Please suggest. if any Module can Fulfill my requirements.

 

Thanks to all for the Great Support.

 

Thanks!!

Link to comment
Share on other sites

Hello All,

 

Have manage the Code to Handle the Manufacturers Level Discount on orders Total.

 

AS there is Some Complications to manage that Discount on products Level (Change Products Price On Shopping Cart) due to Oscommerce Shopping Cart Handling Structure.

So gone to manage the Discount if Applicable for that manufacturers on odder Total level.

 

Thanks to all For their Great Support.

 

Thanks!!

Link to comment
Share on other sites

  • 8 months later...

@@kymation @@Roaddoctor

 

I put a new package together for osC 2.3.4

 

- updated the SQL query to UTF-8

- updated the install manual

- updated all necessary files to work and look like osC 2.3.4

 

Download:

(Before downloading and using it read the stuff below. This version is not ready for production yet!)

 

There is a part inside the checkout_process which I don't fully understand and therefore I am not sure if it is correct to keep the code that way.
In Jim's install manual the checkout_process file has the following code inside.
 

$total_weight += ($order->products[$i]['qty'] * $order->products[$i]['weight']);
    $total_tax += tep_calculate_tax($total_products_price, $products_tax) * $order->products[$i]['qty'];
    $total_cost += $total_products_price;

In osC 2.3.4 the $total_weight, $total_tax and $total_cost part are inside each payment module and not inside the checkout_process.php file.
And according to the install manual you have to add this following code after the above one;
 

// 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']) . "'");

      $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,
                              '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

Here again is a $total_weight inside it which should normally be inside the payment module.
So I am kinda confused as how to handle this part.

The weight is showing correctly inside the checkout_shipping.php so i guess it is OK.

To see and test the weight with the table shipping module amend the following part

//'module' => MODULE_SHIPPING_TABLE_TEXT_TITLE,
  'module' => MODULE_SHIPPING_TABLE_TEXT_TITLE . ' (' . $shipping_num_boxes . ' x ' . $shipping_weight . ' ' . kg .')',

Current bugs are as follows;

 

BUG 1:

I have following setup:

Buy 2 Samsung Galaxy and you get 3 Blade Runner DVDs

Problem:

Now I go to the product_info page of the Samsung Galaxy and add it to the cart.
Now in the shopping cart page I can see 2 Samsung Galaxy and 3 Blade Runner DVDs so far OK.
Now when I change the qty of the Samsung Galaxy to 1 then logically the 3 DVDs should disappear since i don't qualify anymore.
But the DVDs stay and don't disappear. Now when i change the qty of the Samsung Galaxy again back to 2 a new set of 3 DVDs appear.
So I have now 2 Samsung Galaxy, 3 Blade Runner DVDs and again separately listed another 3x Blade Runner DVDs.
Same happens if I try to amend the qty of the free product (3 DVDs) as soon I change the qty of 3 to any other a new set of 3x DVDs appear.
Weird stuff going on right? Ideal would be to not be able to amend the qty of the free products. (so no input field)

 

BUG 2:

 

Once you setup a product inside the admin area (get_1_free.php) and then click on edit the Free Product: dropdown always rests to the product most top in the list. Not really a big deal but annoying.

 

 

I would appreciate if someone could take a look at it and evtl. give me one or two hints as to how to fix this remaining bug(s).

@@kymation I didn't want to upload another package in the add-ons area without your approval and since there is anyway bug(s) still in it i thought we could fix them first and then go from there. Once the normal 2.3.4 version works without problems i would like to convert it for the osC Bootstrap version.

So i would appreciate it if you could look into this package and see if you can see something that i couldn't. Thanks.

 

Edited by Tsimi
Link to comment
Share on other sites

Did more research....and i found the solution to that BUG 1. It was posted somewhere in the middle of this now 20 pages topic.

Post 18 and 49 described the same problem that i had.

http://www.oscommerce.com/forums/topic/255288-get-1-free/?p=1051300
http://www.oscommerce.com/forums/topic/255288-get-1-free/?p=1084966

 

The at post 95 someone posted a fix (3 simple changes) i did 2 of those but forgot the application_top.php part.

http://www.oscommerce.com/forums/topic/255288-get-1-free/?p=1166323

Now all is good except for BUG 2 which is not vital to run this add-on.

IGNORE PREVIOUS PACKAGE! Here is the new fixed package.

 

Download:

 

Next step would be the Bootstrap version.

 

@kymation

 

If you give the OK I would like to upload this package to the add-ons area.

 

 

 

Link to comment
Share on other sites

Forgot to amend the catalog/shopping_cart.php file in the package and include the new get_1_free.php.

 

Here another repack of the Add-on, hopefully complete this time.

Ignore previous packages!

 

 

Edited by Tsimi
Link to comment
Share on other sites

Another and hopefully last package. This one includes also the Bootstrap version. I separated them in two different packages since there are few differences in the code changes and install manual.

 

Any bugs errors or fixes from on will be collected and then put in a final package that will go to the add-ons area as soon Jim signs it off.

 

Final Version (incl. BS version):

Link to comment
Share on other sites

Good work! I don't have time to test this right now, but it looks good. Go ahead and upload it to the Addons area whenever you are satisfied with it. If there are more bugs after that, we'll just have to fix them and upload a new version. Not a big deal.

 

Speaking of versions, should the BS version have a different version number than the stock osC version?

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Speaking of versions, should the BS version have a different version number than the stock osC version?

 

That is a good question. I could upload 2 different versions with 2 different version numbers. It might be better to separate the two to avoid confusion.

Name? Something like v1.5 and v1.5BS?

Edited by Tsimi
Link to comment
Share on other sites

@@Tsimi,

Installed this last night and no problems. Great Job!!

 

Just the nuisance bug when trying to edit an existing entry-

 

Free Product: 

Expiry Date: 

 

are not recalled or remembered and have to be re-entered. The original 2.2 version had the same issue.

-Dave

Link to comment
Share on other sites

@@kymation

 

Will do, thanks for the reminder. :thumbsup:

 

@@Roaddoctor

 

Can you please try this file once?

This should now take care of the expire date issue.

 

 

 

I also have an alternative solution for the Free products name. I can show the name even after clicking on edit but it is not a dropdown so once you chose the first product and the free product it stays like that and if you want to change it you have to delete the entry and add it all over again. Also not a good solution though...(this idea is not implemented in the file above.)

 

I was looking at the country dropdown from the address_book_details.php which always shows the last chosen country name.

Maybe i can find a solution in there...will keep you posted.

Edited by Tsimi
Link to comment
Share on other sites

@@Tsimi

 

noted that line 85 has a duplicate line. Safe to delete the duplicate?

                          products_free_quantity = '" . tep_db_input($products_free_quantity) . "',

I will give your new file a test.

I was trying to sort the same but with same result as you, "see the name but no dropdown". or dropdown but lost selection. Best would be dropdown remains, but the original selection is auto-selected.

 

nice work!

 

 

-Dave

Link to comment
Share on other sites

I solved BUG2 in my version, but it is not using the dropdown

 

I had an issue with the contribution as I have 7000 active products, the dropdown being impractical.

I just have boxes to enter product ids, and I removed the pagination and added other tweaks such as the javascript filtertable

 

I think you can compare and figure out how to do it this way, if that makes sense to  you

 

CarineI

get_1_free.php

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

Attached are the 2 scripts needed for the filter,

php goes in admin/includes/modules

js goes in  (web root) ext/jquery/
 

jquery_filter_table.php

picnet.table.filter.min.js.zip

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

know the feeling, I'll be up till that time tomorrow , not programming for once, I plan to have a superbowl party, a bit of nostalgia as I used to live in New England :rolleyes:

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

I think i solved BUG 2! (w00t)  I just couldn't leave it it bugged me too much....

 

I looked at the orders.php file and saw that the status stays selected after you update the order so if you choose processing then next time you edit the order it still says processing.

So i looked deeper into it and realized that in the get_1_free.php file the function tep_draw_products_pull_down is used and not the regular tep_draw_pull_down_menu. The tep_draw_products_pull_down has the $exclude function inside it to exclude selected products from the dropdown which is not need for the free product but only for the promoted product above.

So I did following changes.

 

admin/get_1_free.php

 

look for this code

 require(DIR_WS_INCLUDES . 'template_top.php');

and add right after it

	// Remember selected free product in the dropdown        
         $free_products = array();
          $free_array = array();
          $free_query = tep_db_query("select p.products_id, pd.products_name, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by products_name");
          while ($free = tep_db_fetch_array($free_query)) {
            $free_products[] = array('id' => $free['products_id'],
                                     'text' => $free['products_name'] . ' (' . $currencies->format($free['products_price']) . ')');
            $free_array[$free['products_id']] = $free['products_name'];
          }

then look for this code

<td class="main"><?php echo tep_draw_products_pull_down('products_free_id', 'style="font-size:10px"'); ?></td>

and replace with

<td class="main"><?php echo tep_draw_pull_down_menu('products_free_id', $free_products, $fInfo->products_free_id); ?></td>

That's it.

I did some test runs and all seems good but if someone else can test and confirm this i would appreciate it.

Link to comment
Share on other sites

UPDATE:

 

fixed BUG3! oh man bugs after bugs showing up. when does it end?

So BUG 2 (free product dropdown issue) and BUG 3 (expire date issue) both are fixed now.

I will not upload the new file to the addons area yet until someone can confirm that this following file.

 

 

Edited by Tsimi
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...