Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Price Break - "Apply code patches" - but how ?


fabianus

Recommended Posts

Posted

If I understand well the ?code patch? makes it possible to change automatically the code of certain files.

 

I have the file included in the feature "Price Break" of Andrew Baucom that defines the changes to make.

 

But I do not have any program to execute (apply) the file! Where can I get that - or if it is included in oscommerce, how do I have to execute it?

 

Thank you very much for any help!

 

fabianus form Paris

Posted

Has anyone tried to create a 'patch' module? Something that works like patch on *nix, which would allow people to apply modules in an easy-to-use fashion.

 

It seems like it might be a fun project.

Posted

Hi,

 

Patch should already be loaded on your server - * I think * it comes

with php. I executed the file from the command line of my server using Putty as

the program.

 

HTH

 

 

Cheers

 

 

Steve

Posted

Even if patch is on the server, it doesn't help you if you can't run shell commands. Most hosts only allow access through FTP or a control panel.

 

A php version that accepted a diff as input and applied the changes to a particular file and offered it for download would be useful (then you could FTP it back up).

 

Cheers,

Matt

Posted

steve worte

"Patch should already be loaded on your server - * I think * it comes with php. I executed the file from the command line of my server using Putty as

the program."

 

- I would be so thankfull if you could tell me how I can execute that patch.

 

Here is the notice concerning the patch :

 

********************************************************************

*

* OSCommerce Patch

*

* Name: Price Break

*

* Author: Andrew Baucom ([email protected])

*

* Purpose: 1) To allow quantity based pricing per product

* 2) To allow the ability to sell a product in

* lots of # quantity only.

*

* Date: August, 2003

*

* Revisions: 5/13/2003 - Initial 1.0 (awb_pb)

* 8/18/2003 - Rewrite 1.1

*

********************************************************************

 

********************************************************************

*** PLEASE READ *** PLEASE READ *** PLEASE READ *** PLEASE READ ***

*** PLEASE READ *** PLEASE READ *** PLEASE READ *** PLEASE READ ***

*** PLEASE READ *** PLEASE READ *** PLEASE READ *** PLEASE READ ***

 

1) This module is to replace the awb_pb module that I had submitted

earlier. Forget about that one.

 

2) NOTE... the products DB table fields have changed from the old

awb_pb module

 

3) This patch was built off of the Milestone 2 version. I won't

be supporting any other versions of oscommerce besides the milestones

and new releases.

 

4) No longer is there a quantity FROM and TO... that was stupid.

Now there is just a single price break quantity level for each

price.

 

********************************************************************

Overview

 

OSCommerce (www.oscommerce.org) open source e-commerce solution

does not by default allow quantity pricing. This module configures

the database and code to allow:

 

1) Quantity pricing per product (currently 4 price break levels)

2) Ability to force products to be sold in lots of # quantity.

 

********************************************************************

Installation (read all steps)

 

0) Backup your code and database.

 

1) Modify the 'products' data table: (MySQL commands shown)

 

alter table products add column products_price1 decimal(15,4) not null default 0.0;

alter table products add column products_price2 decimal(15,4) not null default 0.0;

alter table products add column products_price3 decimal(15,4) not null default 0.0;

alter table products add column products_price4 decimal(15,4) not null default 0.0;

alter table products add column products_price1_qty int not null default 0;

alter table products add column products_price2_qty int not null default 0;

alter table products add column products_price3_qty int not null default 0;

alter table products add column products_price4_qty int not null default 0;

alter table products add column products_qty_blocks int not null default 1;

 

2) If you have already installed my old awb_pb table mods, you will have to drop

those columns and re-add these as they are different.

 

3) Apply code patches to admin and catalog

 

cd /YOUR-MS2-STORE-ROOT

patch -p1 < /WHEREVER/oscommerce-2.2ms2-with-price-break-1.1.diff

 

4) If you do not have access to the 'patch' command. You can find this a

version of MS2 code with this patch installed at...

 

http://www.beezle.com/oscommerce

 

5) I highly recommend that you install this in a test area and not to your

production code/database.

 

6) Please don't email and ask if I have instructions on how to hand modify

these files. I do, it's called the 'patch' file.

 

********************************************************************

Files Modified by this module

 

catalog/admin/categories.php

catalog/admin/includes/languages/english/categories.php

catalog/includes/application_top.php

catalog/includes/classes/PriceFormatter.php

catalog/includes/classes/shopping_cart.php

catalog/includes/languages/english/product_info.php

catalog/includes/modules/product_listing.php

catalog/index.php

catalog/product_info.php

catalog/stylesheet.css

 

********************************************************************

Usage

 

The admin portion of this module allows for extra pricing information

to be entered on the product page. After the standard 'Products Price:'

entry you will find the following fields and is best shown by example.

 

Products Price: _______

Quantity Blocks: _______

Price Break Level 1: _______ Qty: ______

Price Break Level 2: _______ Qty: ______

Price Break Level 3: _______ Qty: ______

Price Break Level 4: _______ Qty: ______

 

 

Example 1:

 

Products Price: 5.00___

Quantity Blocks: 1______

Price Break Level 1: 4.50___ Qty: 10____

Price Break Level 2: 3.95___ Qty: 20____

Price Break Level 3: 3.85___ Qty: 30____

Price Break Level 4: 3.75___ Qty: 40____

 

* The standard price of this item is 5.00 for quantities less than 10.

* If the customer orders 10 or more, the price is 4.50/each

* If the customer orders 20 or more, the price is 3.95/each

* If the customer orders 30 or more, the price is 3.85/each

* If the customer orders 40 or more, the price is 3.75/each

 

 

Example 2:

 

Products Price: 3.75___

Quantity Blocks: 1______

Price Break Level 1: 0.00___ Qty: 0_____

Price Break Level 2: 0.00___ Qty: 0_____

Price Break Level 3: 0.00___ Qty: 0_____

Price Break Level 4: 0.00___ Qty: 0_____

 

* This product has the standard price of 3.75.

* The customer can purchase this product in any number of units.

* No price breaks are in affect.

 

 

Example 3:

 

Products Price: 5.00___

Quantity Blocks: 12_____

Price Break Level 1: 4.00___ Qty: 24____

Price Break Level 2: 3.00___ Qty: 36____

Price Break Level 3: 2.00___ Qty: 48____

Price Break Level 4: 0.00___ Qty: 0_____

 

* The standard price of this item is 5.00/each.

* The customer can purchase this product only in lots of 12 units.

* The shopping cart will automatically round up to the nearest 12.

* If the customer orders 24 or more, the price is 4.00/each

* If the customer orders 36 or more, the price is 3.00/each

* If the customer orders 48 or more, the price is 2.00/each

 

 

 

********************************************************************

Legal

 

* SEE THE LICENCE FILE *

Posted

Matt hit it on the head.

 

On my host, I do not have ssh/telnet access for 'security reasons'. I only have ftp and some other basic admin function thru a control panel type interface.

 

I was thinking more of a php script that could take a specially formatted file as input (e.g. coolmenu.oscpatch.spec) and a tarball of files (e.g. coolmenu.oscpatch.tgz) and use php functions to apply the patch.

 

Obviously there would be checks in there (like patch) to make sure that the final resultant files would be correct.

  • 2 months later...
Posted

FYI

 

I just posted a file by file set of installation instructions for the Price Break contribution.

 

http://www.oscommerce.com/community/contributions,1242

 

I just compared Andrew Baucom's complete MS2 code against the standard MS2 release and documented the changes.

 

I don't pretend to understand all of the script. I am a complete newbie when it comes to PHP.

Rule #1: Without exception, backup your database and files before making any changes to your files or database.

Rule #2: Make sure there are no exceptions to Rule #1.

  • 2 months later...
Posted

Oh my, you are right GraphicsGuy you don't do php very well........you made a mistake somewhere because there is nothing to change on the file catalog/product_info.php

 

and right now you lucky you are not in my house....lol.

 

Glad I was smart enough to make a backup copy before I started to do all that find and replace shit.

 

 

To bad contributions are not like in Dreamweaver and such......would be so great for us non-geek, code thriving, _ _ _ _ fill in the blanks, that forget the rest of us here didn't learn to read code and write code before we were toilit traine......rofl

 

Signed

A bit miffed at GraphicsGuy

AKA Kel

I live in my own little world. But it's OK. They know me here.

Posted

mrsc2003,

 

:( Sorry it didn't work for you. I hope you aren't too seriously miffed. I am glad that you backed up first. That is always essential.

 

In my defense I can only say that it worked for me and restate that I didn't author the code and reiterate:

 

I just compared Andrew Baucom's complete MS2 code against the standard MS2 release and documented the changes.

 

and from the contrib:

 

I take no credit (good or bad) for the Price Break contribution.

 

This set of instructions is something I assembled by comparing the complete MS2 code provided by Andrew Baucom to the official stock MS2 release.

 

I am a novice with PHP and I make no pretense of understanding every piece of this code. I just compared the code and documented the differences.

 

The original contribution is in the form of a diff file. This works easy if you are applying it against a stock MS2 install. But it is quite a challenge to install it if you have a heavily modded store.

 

Regarding:

you made a mistake somewhere because there is nothing to change on the file catalog/product_info.php

 

:huh: Changes for product_info.php are detailed in the file catalog_product_info.txt:

 

File to be altered:  catalog/product_info.php

 

 

=========================

Find:

 

    $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

 

Change to:

 

    $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_price1,p.products_price2,p.products_price3,p.products_price4,p.produc

ts_price1_qty,p.products_price2_qty,p.products_price3_qty,p.products_price4_qty,p

.products_qty_blocks, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

 

 

=========================

Find:

 

    if ($new_price = tep_get_products_special_price($product_info['products_id'])) {

      $products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';

    } else {

      $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));

    }

 

Change to:

 

    $pf->loadProduct((int)$HTTP_GET_VARS['products_id'], (int)$languages_id);

    $products_price=$pf->getPriceString();

 

=========================

 

Find:

 

<td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>

 

Change to:

 

                <td class="main" align="right">

<table border="0" align="right">

<tr><td alignt="center">

<?php echo TEXT_ENTER_QUANTITY . ":" . tep_draw_input_field('cart_quantity', $pf->adjustQty(1), 'size="6"'); ?>

</td></tr>

<tr><td align="center">

<?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?>

</td></tr>

</table>

  </td>

Rule #1: Without exception, backup your database and files before making any changes to your files or database.

Rule #2: Make sure there are no exceptions to Rule #1.

Posted

I know where the file is .....lol, just none what was on your file matched my file........rofl.

 

I did install BTs template first so maybe that was my downfall :(

 

But hey, after transplanting a half dozen rose bushes and doing some minor weeding in the soon to be vegie garden I am now ready to start over again.

 

If you come to my house and set it up for me I will give you some fresh vegies in the fall......... ;)

 

 

Kel

I live in my own little world. But it's OK. They know me here.

Posted

That is the hard part - making different contribs work and play together well.

 

That is why I chose to do this to the price break mod. My store is heavily modified and to apply the diff file was pretty much impossible.

 

So I took a bare MS2 stock install, applied the diff file and then used Winmerge to identify the differences and write the instructions. Then I used the instruction set to apply it to my store. That way when it interacted with other mods, I could work it out.

 

I appreciate the work for food offer. :) I'm afraid I will have to pass this time though.

Rule #1: Without exception, backup your database and files before making any changes to your files or database.

Rule #2: Make sure there are no exceptions to Rule #1.

Posted

giggles.....oh well just more for the rabbits

I live in my own little world. But it's OK. They know me here.

  • 2 weeks later...
Posted

I just got Price Break working on my site by following the directions. Thanks! I was also able to integrate it into Easy Populate by cutting and pasting.

 

Dave Wilson

  • 1 month later...
Posted

I would like to get the Price Break showing on the product listing page.

 

Any idea how to do this? I am a newbie and completely stumped ;)

 

Thanks,

 

Donna Gordon

  • 1 month later...
Posted
I just got Price Break working on my site by following the directions. Thanks! I was also able to integrate it into Easy Populate by cutting and pasting.

 

Dave Wilson

Any chance you could share your work?

 

I can't seem to get mine to work.

Posted

yeah i would like to see it too, i cant get price break to work, it only shows three price breaks no matter how many i put in the admin side.

Posted

I have it working due to the fact that I just copied all the files over. But that was a very new install way back then. The more add-ons you install the harder it gets to have everything work. I found it is better to compare code if it is a page(file) that is already in the cat. And sometimes the contributions have code errors in them also. Amazing how a forgotten . or > or { can really screw things up.

 

Kel

 

Kel's Corner Store

I live in my own little world. But it's OK. They know me here.

  • 5 months later...
Posted

I have this all working except when I pick 20 it still gives the price for the default amount it all working in admin letting me set different prices but always the wrong price when I add to the cart any ideas?

 

My Webpage

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...