Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

Hi everybody,

umptheenth problem... using the product attributes I noticed that I can only add or subtract a price, but I cannot replace it.

 

I need to find a way to replace the price...

 

Example: if the White item costs "10" and I select the option "blue" in the attributes with price "12", oscommerce calculates 10 + 12. Instead of this, I would like oscommerce to consider 12 directly.

 

Do you know a way to manage prices like this? I suggest to introduce the option " = " to allow the system to replace the price instead of add it.

 

Bye

Compliments for the forum, it is always an excellent section to find solutions...

 

Paolo

Posted

Well, it might be hard to find this solution under "Shipping Modules"!

 

You could make the base price zero and use the attribute to add the actual cost. But this seems a rather odd use of attributes. You could tweak the code to not display the "+" , but the product would show as zero cost elsewhere.

 

What sort of thing are you selling that you want this solution for?

Posted

Hi, thanks for your answer.

I considered to choose 0 as base price but it is not very suitable: the user would visualize the products with price 0 in the categories, then he would discover the real price in the detail.

 

What I need is to visualize the base price.

E.g. base price "10" for the small product, when the user selects the big product in the attributes the price should be replaced with the attribute price, for example 12.

 

I thought to add the sign " =" besides " + " and " - "

 

I have already tried to change the code strings, but useless, because the total amount is out

 

I think the function to be modified is (shopping_Cart.php):

 

// products price

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

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

$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'];

 

$specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$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 += tep_add_tax($products_price, $products_tax) * $qty;

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

}

 

// attributes price

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

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

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 = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");

$attribute_price = tep_db_fetch_array($attribute_price_query);

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

$this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);

} else {

$this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);

}

}

}

}

}

 

function attributes_price($products_id) {

$attributes_price = 0;

 

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

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

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 = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");

$attribute_price = tep_db_fetch_array($attribute_price_query);

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

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

} else {

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

}

}

}

 

return $attributes_price;

}

 

 

 

Thank you.

Bye

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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...