Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product Attributes - Option Type Feature


travisb

Recommended Posts

I am using the Product Attributes - Option Type Feature contribution and need a little help. I have some text boxes with value prices added. Does anyone know how to get the Value Price added to the product in the shopping cart if the text box is filled out? Right now, the option shows up in the cart, but the option price is not added to the product price.

Link to comment
Share on other sites

I was able to reproduce this problem, I'll let you know if I find the solution

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 made the following 2 changes to have the TEXT price included:

You basically build in a switch to see if it's a text attribute and in that case ignore the option_values_id for the selection of the pricing data. Remember, text fields all have options_id set to 0 (or other constant that you defined). There can only be one text field for each product, thus it is safe to ignore the option_values_id

 

In catalog/includes/classes/shopping_cart.php in the calculate function:

// 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'])) {
        	 //BoF CB also fetch the price if $value is a TEXT string
           //$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 . "'");
           if  ($value == PRODUCTS_OPTIONS_VALUE_TEXT_ID) {
             $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 . "' ");
           } else {
             $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 . "'");
           };
           //EoB CB switch for TEXT string
           
           $attribute_price = tep_db_fetch_array($attribute_price_query);

 

and in the attributes_price function

    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'])) {
        	 //BoF CB also fetch the price if $value is a TEXT string
           //$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 . "'");
           if  ($value == PRODUCTS_OPTIONS_VALUE_TEXT_ID) {
             $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 . "' ");
           } else {
             $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 . "'");
           };
           //EoB CB switch for TEXT string

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

Thank you very much bruyndoncx.

 

:D :D :D

 

I thought I had the email notification turned on, or else I would have replied, and had the solution, last week. We are very excited to have this working now.

Thanks again,

Travis

 

I made the following 2 changes to have the TEXT price included:

You basically build in a switch to see if it's a text attribute and in that case ignore the option_values_id for the selection of the pricing data. Remember, text fields all have options_id set to 0 (or other constant that you defined). There can only be one text field for each product, thus it is safe to ignore the option_values_id

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

Hello from germany,

 

I would gladly apreciate any help for the following problem:

 

Is it possible to add the attributes price only once per product, independent of how many of this item would be purchased?

I will try to explain it using an example. I am building an onlineshop for a printing company. So i created a product called envelopes. As attributes i have defined "Number of colours", here 4C or single colour. If i add a price for this attribute, it will be summed up, if someone orders 10 envelopes, it will cost him 10 times the "number of colours" price. Since this option should be the price for the basic costs for the printing job, it only has to be added once per product. Any idea how to get this running?

Second example: If someone wants to buy some envelopes, he will have to pay a basic fee, depending on the number of colours. This price will not change, wether he buys 100 or 1000 envelopes. If he now wants to buy stationery also, he again has to pay another (different) basic fee, because the stationery will be printed on another printer.

I hope, that I have explained my problem somehow, my english is not that good. Probably one of the osCommerce specialists out there could help me with that?

 

Thank you very much

 

Andr?

Edited by Elvis
Link to comment
Share on other sites

Hello from Norway!

 

I also run a print shop and need exactly the same as you do. I have spent a lot of time searching the forums with no luck this far! I consider hiring a programmer to do this if nothing comes up here.

 

Vidar

 

 

Hello from germany,

 

I would gladly apreciate any help for the following problem:

 

Is it possible to add the attributes price only once per product, independent of how many of this item would be purchased?

I will try to explain it using an example. I am building an onlineshop for a printing company. So i created a product called envelopes. As attributes i have defined "Number of colours", here 4C or single colour. If i add a price for this attribute, it will be summed up, if someone orders 10 envelopes, it will cost him 10 times the "number of colours" price. Since this option should be the price for the basic costs for the printing job, it only has to be added once per product. Any idea how to get this running?

Second example: If someone wants  to buy some envelopes, he will have to pay a basic fee, depending on the number of colours. This price will not change, wether he buys 100 or 1000 envelopes. If he now wants to buy stationery also, he again has to pay another (different) basic fee, because the stationery will be printed on another printer.

I hope, that I have explained my problem somehow, my english is not that good. Probably one of the osCommerce specialists out there could help me with that?

 

Thank you very much

 

Andr?

Link to comment
Share on other sites

It may or may not work, but you can look at the problem differently.

 

Suppose your smallest batch size is 10 costing 120 where 20 is the fixed fee and 100 for 10 envelopes.

 

Setting up base product as 120 with batch of 10 selected by default.

Then you can add option to have 100 at +90, 200 + 190 etc

 

There is also a small contribution to implement a mulitplication factor which might be useful too.

 

HTH

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

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