Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Price based on percentage


dewards

Recommended Posts

Posted

I have searched through the contributions and on the forums but cannot find a contribution to do this. I base my prices on a percentage markup. Meaning that I take my cost and add X% to that price to determine the price that my customer's will pay. I was wondering if there is a contribution that would allow me to enter my cost for each item instead of the customer's price when entering each item, and then be able to have the store to by default increase that amount my a percentage that I would set in the admin panel. This would make it very easy if I chose to raise/lower prices on an overal basis and make sure that any future items added would be based on the same percentage. I hope this made sense, if not let me know and I will try to explain better. I do not know much about php beyond being able to install contributions.

  • 2 weeks later...
Posted
I have searched through the contributions and on the forums but cannot find a contribution to do this.  I base my prices on a percentage markup.  Meaning that I take my cost and add X% to that price to determine the price that my customer's will pay.  I was wondering if there is  a contribution that would allow me to enter my cost for each item instead of the customer's price when entering each item, and then be able to have the store to by default increase that amount my a percentage that I would set in the admin panel.  This would make it very easy if I chose to raise/lower prices on an overal basis and make sure that any future items added would be based on the same percentage.  I hope this made sense, if not let me know and I will try to explain better.  I do not know much about php beyond being able to install contributions.

 

I am interested in something similar too however I have three pricing structures i.e. three different precentages that I base price off of my cost + % of profit. I've went crazy looking online at systems that handled dymanic e-commerce pricing and came up short with both pay and non-pay solutions which took a product, expected a price and generated the cart. Any development in this area would be GREATLY appreciated.

  • 1 month later...
Posted

I also would very much like to see a contribution like this [is there currently one?]

 

I'm not too fussed about the admin side of things as I don't mind going into the database and changing the overall percent manually.

 

Ian

Posted

If you use Easy Populate to import your products, you can easily set any markup (based on 1 or more tiers) using basic Excel functions.

 

You can also use a "1 line" mysql script that can raise (or lower) all of your existing prices by a certain percentage using phpmyadmin.

 

HTH,

Robert

Posted
I have searched through the contributions and on the forums but cannot find a contribution to do this.  I base my prices on a percentage markup.  Meaning that I take my cost and add X% to that price to determine the price that my customer's will pay.  I was wondering if there is  a contribution that would allow me to enter my cost for each item instead of the customer's price when entering each item, and then be able to have the store to by default increase that amount my a percentage that I would set in the admin panel.  This would make it very easy if I chose to raise/lower prices on an overal basis and make sure that any future items added would be based on the same percentage.  I hope this made sense, if not let me know and I will try to explain better.  I do not know much about php beyond being able to install contributions.

 

 

Will this help? You can modify it to fit your needs...

 

This code allows one to add to the product attributes options the multiplication operand 'x' alongwith the '+' & '-' ones which is like adding an percentage attribute option. I found this pretty useful for cases where a multiple increase is required like 1.25 times the basic price especially for hotel room rates etc. It is a time saver in times of price meltdowns, premiums over basic cost etc. as it automatically changes the price without manual changes as in the case with the other operands.

Also, i have added a few tweaks to display the actual atrributes in the checkout page eg. basic price x 1.25 times. U can change them according to your display format needs. The operand used is small 'x' for multiplication in the products attribute options in the admin module.

 

note : there is just a minimum change required to a database table which is not absolutely necessary but it helps in a better reading of prices during billing, printorders etc. Just change the INT value of options_values_price field in the table product_attributes to Decimal(15.2) from Decimal(15.4). thats it.

 

since a lot of changes have occured in my files due to the various hacks, i am only enclosing the manual changes in here. they are very simple additions to the files so it should be easy for anyone to incorporate them. also, since i am a part time programmer, i will not be able to entertain queries etc. due to time constraints. so please do this at your risk and backup the to-be-modified files first.

 

 

 

 

check in the following files & make the changes as defined by bof and eof.

 

 

 

**** step 1 : In \catalog\shopping_cart.php in catalog catalog directory

 

 

if ($attributes_exist == '1') {

reset($cart->contents[$products[$i]['id']]['attributes']);

//----------------bof

$x_ctr = 0;

//----------------eof

while (list($option, $value) = each($cart->contents[$products[$i]['id']]['attributes'])) {

$attributes = tep_db_query("select pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $products[$i]['id'] . "' and pa.options_id = '" . $option . "' and pa.options_values_id = '" . $value . "'");

$attributes_values = tep_db_fetch_array($attributes);

if ($attributes_values['options_values_price'] != '0') {

//--------------------------------------------------bof

if ($attributes_values['price_prefix'] != 'x') {

$attributes_values['options_values_price'] = $products[$i]['quantity'] * $attributes_values['options_values_price'];

echo "\n" . '<br><small><i>' . $attributes_values['price_prefix'] . $currencies->display_price($attributes_values['options_values_price'],tep_get_tax_rate($products[$i]['tax_class_id'])) . '</i></small>';

} else {

$temp = $attributes_values['options_values_price'];

$x_ctr = $x_ctr + 1;

if ($x_ctr <= 1) {

$attributes_values['options_values_price'] = $products[$i]['price'] * ($attributes_values['options_values_price']);

$total_price = $attributes_values['options_values_price'];

echo "\n" . '<br><small><i>' . '(cost ' . $attributes_values['price_prefix'] . ' ' . $temp . ') = ' . '</i></small>' . $currencies->display_price($attributes_values['options_values_price'],tep_get_tax_rate($products[$i]['tax_class_id']));

} else {

$attributes_values['options_values_price'] = $total_price * ($attributes_values['options_values_price']);

$total_price = $attributes_values['options_values_price'];

echo "\n" . '<br><small><i>' . '(cost ' . $attributes_values['price_prefix'] . ' ' . $temp . ') = ' . '</i></small>' . $currencies->display_price($attributes_values['options_values_price'],tep_get_tax_rate($products[$i]['tax_class_id']));

}

}

//-------------------------------eof

} else {

// Keep price aligned with corresponding option

$attributes_values['options_values_price'] = $products[$i]['price'];

echo "\n" . '<br><small><i> </i></small>';

}

}

}

//------display customer choosen option eof-----

echo '</td>' . "\n";

echo ' </tr>' . "\n";

}

 

******step 2 : changes in /catalog/classes/shopping_cart.php

 

function calculate() {

$this->total = 0;

$this->weight = 0;

if (!is_array($this->contents)) return 0;

 

reset($this->contents);

while (list($products_id, ) = each($this->contents)) {

$qty = $this->contents[$products_id]['qty'];

 

// products price

$product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id='" . tep_get_prid($products_id) . "'");

if ($product = tep_db_fetch_array($product_query)) {

// ICW ORDER TOTAL CREDIT CLASS Start Amendment

$no_count=1;

$gv_query=tep_db_query("select products_model from ".TABLE_PRODUCTS." where products_id='".$products_id."'");

$gv_result=tep_db_fetch_array($gv_query);

if (ereg('^GIFT', $gv_result['products_model'])) {

$no_count=0;

}

// ICW ORDER TOTAL CREDIT CLASS End Amendment

$prid = $product['products_id'];

$products_tax = tep_get_tax_rate($product['products_tax_class_id']);

$products_price = $product['products_price'];

$products_weight = $product['products_weight'];

//---------------------------------------------------------------------------------bof

$specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . $prid . "' and status = '1'");

if (tep_db_num_rows ($specials_query)) {

$specials = tep_db_fetch_array($specials_query);

$products_price = $specials['specials_new_products_price'];

}

// $this->total += $products_price * $qty;

$total_price = $products_price;

//$this->total += tep_add_tax($products_price, $products_tax) * $qty;

//---------------------------------------------------------------------------------eof

$this->weight += ($qty * $products_weight);

$this->total_virtual += tep_add_tax($products_price, $products_tax) * $qty*$no_count;// CREDIT CLASS;

$this->weight_virtual += ($qty * $products_weight)*$no_count;// CREDIT CLASS;

}

 

// attributes price

if ($this->contents[$products_id]['attributes']) {

reset($this->contents[$products_id]['attributes']);

//----------------------------bof

$x_ctr = 0;

//----------------------------eof

while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {

$attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $prid . "' and options_id = '" . $option . "' and options_values_id = '" . $value . "'");

$attribute_price = tep_db_fetch_array($attribute_price_query);

//----------------------------------------------------------------bof

if ($attribute_price['price_prefix'] == '+') {

$this->total += $qty * $attribute_price['options_values_price'];

}

if ($attribute_price['price_prefix'] == '-') {

$this->total -= $qty * $attribute_price['options_values_price'];

}

if ($attribute_price['price_prefix'] == 'x') {

$x_ctr = $x_ctr + 1;

if ($x_ctr <= 1) {

$total_price = $products_price * ($attribute_price['options_values_price']);

} else {

$total_price = $total_price * ($attribute_price['options_values_price']);

}

}

}

// $total_price -= $products_price;

}

//}

$this->total += $qty * tep_add_tax($total_price, $products_tax);

//$this->total += $qty * $total_price;

//-------------------------------------------------------------------eof

}

}

 

function attributes_price($products_id) {

if ($this->contents[$products_id]['attributes']) {

reset($this->contents[$products_id]['attributes']);

//----------bof

$x_ctr = 0;

eof

$end_ctr = 0;

$specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . $products_id . "' and status = '1'");

//----------eof

while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {

 

$attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $products_id . "' and options_id = '" . $option . "' and options_values_id = '" . $value . "'");

$attribute_price = tep_db_fetch_array($attribute_price_query);

//----------------------------------------------------------------------------bof

$temp_price_query = tep_db_query("select products_price from " . TABLE_PRODUCTS . " where products_id = '" . $products_id . "'");

$temp_price = tep_db_fetch_array($temp_price_query);

 

$specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . $products_id . "' and status = '1'");

 

if (tep_db_num_rows ($specials_query)) {

$specials = tep_db_fetch_array($specials_query);

$temp_price['products_price'] = $specials['specials_new_products_price'];

//$attributes_price = $specials['specials_new_products_price'];

}

 

if ($attribute_price['price_prefix'] == '+') {

$attributes_price += $attribute_price['options_values_price'];

}

if ($attribute_price['price_prefix'] == '-') {

$attributes_price -= $attribute_price['options_values_price'];

}

if ($attribute_price['price_prefix'] == 'x') {

$x_ctr = $x_ctr + 1;

if ($x_ctr <= 1) {

$attributes_price = $temp_price['products_price'] * ($attribute_price['options_values_price']);

$total_price = $attributes_price;

} else {

$attributes_price = $total_price * ($attribute_price['options_values_price']);

$total_price = $attributes_price;

}

}

}

if ($x_ctr >= 1) {

$attributes_price -= $temp_price['products_price'];

}

}

//----------------------------------------------------------------------------eof

return $attributes_price;

 

}

 

 

 

**** and also change the product array around end of the file :

 

$products_array[] = array('id' => $products_id,

'name' => $products['products_name'],

'model' => $products['products_model'],

'price' => $products_price,

'quantity' => $this->contents[$products_id]['qty'],

'weight' => $products['products_weight'],

//---------------------------------------------bof

//'final_price' => ($products_price + $this->attributes_price($products_id)),

'final_price' => ($this->attributes_price($products_id)),

//---------------------------------------------eof

'tax_class_id' => $products['products_tax_class_id'],

'attributes' => $this->contents[$products_id]['attributes']);

}

 

 

***** step 3 : change /catalog/checkout_confirmation.php

 

if (sizeof($order->products[$i]['attributes']) > 0) {

for ($j=0; $j<sizeof($order->products[$i]['attributes']); $j++) {

echo '<br><nobr><small> <i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];

 

if ($order->products[$i]['attributes'][$j]['price'] != '0') {

//----------------------------------------------------------------------bof

if ($order->products[$i]['attributes'][$j]['prefix'] != 'x') {

echo ' (' . ($order->products[$i]['attributes'][$j]['prefix']) . $currencies->format($order->products[$i]['attributes'][$j]['price'] * $order->products[$i]['qty']) . ')';

echo '</i></small></nobr>';

} else {

echo ' (' . ($order->products[$i]['attributes'][$j]['prefix']) . ' ' . $order->products[$i]['attributes'][$j]['price'] . ' ' . 'times' . ')';

echo '</i></small></nobr>';}

}

//----------------------------------------------------------------------bof

}

}

 

echo '</td>' . "\n" .

' <td class="main" align="right" valign="top">' . tep_display_tax_value($order->products[$i]['tax']) . '%</td>' . "\n";

echo ' <td class="main" align="right" valign="top">' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . '</td>' . "\n";

echo ' </tr>' . "\n";

}

Life should be completed with you skidding in sideways

all worn out screaming "Holy Crap..What A Ride"

www.studio143vr.com

  • 2 months later...
Posted
If you use Easy Populate to import your products, you can easily set any markup (based on 1 or more tiers) using basic Excel functions.

 

You can also use a "1 line" mysql script that can raise (or lower) all of your existing prices by a certain percentage using phpmyadmin.

 

HTH,

Robert

 

I will look over that contribution. I had avoided many of those as I use the meta tags contribution and would hate to have to go back for all items and reenter all of that information. I was looking for something where I would enter my cost for the item when I was entering it and then be able to quickly adjust the percentage of markup as needed without the customer ever seeing my price.

Archived

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

×
×
  • Create New...