Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product Attributes - Option Type Feature


Recommended Posts

I have installed the Product Attributes contribution and it puts text boxes in the product optionsjust like I wanted but once you have added the item to the basket it will keep the headings for the other items but not for the text boxes like this:

 

Large Personalised Heart

- line 1

- line 2

- line 3

- Flower Style: Flower & Heart

- Flower Colour: None

 

When what I want is

 

Large Personalised Heart

- Text Line 1: line 1

- Text Line 2: line 2

- Text Line 3: line 3

- Flower Style: Flower & Heart

- Flower Colour: None

 

This link takes you to the contribution where there is a manual install page but I don't know enough coding to work out where it needs altering

 

Can anyone help?

 

http://www.oscommerce.com/community/contributions,160/page,7

 

Thanks

Link to comment
Share on other sites

  • 4 weeks later...
I have installed the Product Attributes contribution and it puts text boxes in the product optionsjust like I wanted but once you have added the item to the basket it will keep the headings for the other items but not for the text boxes like this:

 

Large Personalised Heart

- line 1

....

When what I want is

 

Large Personalised Heart

- Text Line 1: line 1

....

 

Can anyone help?

 

Thanks

 

Hi, I had the same need as you .. I'm new to osC .. and have only built one full commercial site so far .. my client wanted this problem fixed as well .. After many hours of tracking through the code I decided, with my limited knowledge, that the existing code should work but it doesn't !.. so I coded around the problem by intercepting and assigning the name of the Line whenever a Text-type Attribute was being used.

 

To do the full job you need to alter the code in 3 files:

1. cat/shopping_cart.php around line 110

2. cat/includes/classes/order.php around line 273 (for the checkout confirmation process)

3. cat/checkout_process.php around line 196 for inserting the names into the orders database and around line 233 for the customers email confirmation.

 

I have given the code changes for 1. only here ... if you can use it/get it to work email me and I will post the rest of the code.

 

I have pasted in lines 77-126 from my code .. ignore the "// RWD notes" and look for the "// RWD addition ...".

If you are careful you should be able to merge your code and this code manually.

 

Note: clr is the original Options Type Feature - I love it,all quodos to its creator. I'm RWD (RoseWeb Designs)

 

   for ($i=0, $n=sizeof($products); $i<$n; $i++) {
// Put all attributes information in an array
     if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
       while (list($option, $value) = each($products[$i]['attributes'])) {
         //clr 030714 move hidden field to if statement below (OTR)
         //echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . $option . ']', $value);
         $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix
                                     from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                                     where pa.products_id = '" . $products[$i]['id'] . "'
                                      and pa.options_id = '" . $option . "'
                                      and pa.options_id = popt.products_options_id
                                      and pa.options_values_id = '" . $value . "'
                                      and pa.options_values_id = poval.products_options_values_id
                                      and popt.language_id = '" . $languages_id . "'
                                      and poval.language_id = '" . $languages_id . "'");
         $attributes_values = tep_db_fetch_array($attributes);

         //clr 030714 determine if attribute is a text attribute and assign to $attr_value temporarily (OTR)
         if ($value == PRODUCTS_OPTIONS_VALUE_TEXT_ID) {
           echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . TEXT_PREFIX . $option . ']',  $products[$i]['attributes_values'][$option]);

// RWD note:  - text attributes value is assigned to temp variable $attr_value in this If TEXT code but ... see below

         $attr_value = $products[$i]['attributes_values'][$option];


         } else {
           echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . $option . ']', $value);
           $attr_value = $attributes_values['products_options_values_name'];
         }
//RWD Note: this line assigns the option name - works for all except text options - see my add-on  below this
         $products[$i][$option]['products_options_name'] = $attributes_values['products_options_name'];

// RWD addition to collect text field's name
if ($value == PRODUCTS_OPTIONS_VALUE_TEXT_ID) {
         $rwd_attributes = tep_db_query("SELECT products_options.products_options_id, products_options.products_options_name  FROM products_options
            WHERE products_options.products_options_id = '".$option."'");
             $rwd_attributes_values = tep_db_fetch_array($rwd_attributes);
             $products[$i][$option]['products_options_name'] = $rwd_attributes_values['products_options_name'];
}
// EOF RWD addition to name text field

         $products[$i][$option]['options_values_id'] = $value;
         //clr 030714 assign $attr_value (OTR)
         $products[$i][$option]['products_options_values_name'] = $attr_value ;
         $products[$i][$option]['options_values_price'] = $attributes_values['options_values_price'];
         $products[$i][$option]['price_prefix'] = $attributes_values['price_prefix'];
       }
     }
   }

 

Good Luck

Carl

Link to comment
Share on other sites

  • 6 months later...

On a request from bayleon(James) here is the code for:

step 2: cat/includes/classes/order.php around line 273 (for the checkout confirmation process)

Find this code(shown below). Look for my insert (RWD addition...) and put it in

 

        if ($products[$i]['attributes']) {
         $subindex = 0;
         reset($products[$i]['attributes']);
         while (list($option, $value) = each($products[$i]['attributes'])) {
           $attributes_query = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . (int)$products[$i]['id'] . "' and pa.options_id = '" . (int)$option . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . (int)$value . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . (int)$languages_id . "' and poval.language_id = '" . (int)$languages_id . "'");
           $attributes = tep_db_fetch_array($attributes_query);

//clr 030714 Determine if attribute is a text attribute and change products array if it is.
           if ($value == PRODUCTS_OPTIONS_VALUE_TEXT_ID){
             $attr_value = $products[$i]['attributes_values'][$option];
           } else {
             $attr_value = $attributes['products_options_values_name'];
           }

// RWD addition to collect text field's name and assign it
if ($value == PRODUCTS_OPTIONS_VALUE_TEXT_ID) {
         $rwd_attributes = tep_db_query("SELECT products_options.products_options_id, products_options.products_options_name  FROM products_options
            WHERE products_options.products_options_id = '".$option."'");
             $rwd_attributes_values = tep_db_fetch_array($rwd_attributes);
             $attributes['products_options_name'] = $rwd_attributes_values['products_options_name'];
}
// EOF RWD addition to name text field

           $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options_name'],
                                                                    'value' => $attr_value,
                                                                    'option_id' => $option,
                                                                    'value_id' => $value,
                                                                    'prefix' => $attributes['price_prefix'],
                                                                    'price' => $attributes['options_values_price']);
           $subindex++;
         }
       }

 

Happy coding.

Carl B)

Link to comment
Share on other sites

On a request from bayleon(James) here is the code for:

3. cat/checkout_process.php around line 196 for inserting the names into the orders database and around line 233 for the customers email confirmation.

Find this code(shown below). Look for my inserts[THERE ARE TWO] (RWD addition...) and put them in

 

    if (isset($order->products[$i]['attributes'])) {
     $attributes_exist = '1';
     for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
       if (DOWNLOAD_ENABLED == 'true') {
         $attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename
                              from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                              left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
                               on pa.products_attributes_id=pad.products_attributes_id
                              where pa.products_id = '" . $order->products[$i]['id'] . "'
                               and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "'
                               and pa.options_id = popt.products_options_id
                               and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "'
                               and pa.options_values_id = poval.products_options_values_id
                               and popt.language_id = '" . $languages_id . "'
                               and poval.language_id = '" . $languages_id . "'";
         $attributes = tep_db_query($attributes_query);
       } else {
         $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'");
       }
       $attributes_values = tep_db_fetch_array($attributes);


// RWD Insert to collect text field's name and put it into the array that updates the database

       if ($order->products[$i]['attributes'][$j]['value_id'] == PRODUCTS_OPTIONS_VALUE_TEXT_ID){
         $rwd_attributes = tep_db_query("SELECT products_options.products_options_id, products_options.products_options_name  FROM products_options
            WHERE products_options.products_options_id = '".$order->products[$i]['attributes'][$j]['option_id']."'");
             $rwd_attributes_values = tep_db_fetch_array($rwd_attributes);
             $rwd_products_options_name = $rwd_attributes_values['products_options_name'];

             $sql_data_array = array('orders_id' => $insert_id,
                               'orders_products_id' => $order_products_id,
                               'products_options' => $rwd_products_options_name,
                               'products_options_values' => $order->products[$i]['attributes'][$j]['value'],
                               'options_values_price' => $attributes_values['options_values_price'],
                               'price_prefix' => $attributes_values['price_prefix']);

             } else {

			//clr 030714 update insert query.  changing to use values form $order->products for products_options_values.
        $sql_data_array = array('orders_id' => $insert_id,
                               'orders_products_id' => $order_products_id,
                               'products_options' => $attributes_values['products_options_name'],
                               'products_options_values' => $order->products[$i]['attributes'][$j]['value'],
                               'options_values_price' => $attributes_values['options_values_price'],
                               'price_prefix' => $attributes_values['price_prefix']);
                     }

       tep_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);

       if ((DOWNLOAD_ENABLED == 'true') && isset($attributes_values['products_attributes_filename']) && tep_not_null($attributes_values['products_attributes_filename'])) {
         $sql_data_array = array('orders_id' => $insert_id,
                                 'orders_products_id' => $order_products_id,
                                 'orders_products_filename' => $attributes_values['products_attributes_filename'],
                                 'download_maxdays' => $attributes_values['products_attributes_maxdays'],
                                 'download_count' => $attributes_values['products_attributes_maxcount']);
         tep_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array);
       }

// RWD Insert to collect text field's name for the EMAIL CONFIRMATION

       if ($order->products[$i]['attributes'][$j]['value_id'] == PRODUCTS_OPTIONS_VALUE_TEXT_ID){
         $rwd_attributes = tep_db_query("SELECT products_options.products_options_id, products_options.products_options_name  FROM products_options
            WHERE products_options.products_options_id = '".$order->products[$i]['attributes'][$j]['option_id']."'");
             $rwd_attributes_values = tep_db_fetch_array($rwd_attributes);
             $rwd_products_options_name = $rwd_attributes_values['products_options_name'];
             $products_ordered_attributes .= "\n\t" . $rwd_products_options_name. ' = ' . tep_decode_specialchars($order->products[$i]['attributes'][$j]['value']);

} else {
			//clr 030714 changing to use values from $orders->products and adding call to tep_decode_specialchars()
       $products_ordered_attributes .= "\n\t" . $attributes_values['products_options_name'].' = ' . tep_decode_specialchars($order->products[$i]['attributes'][$j]['value']);
     //$products_ordered_attributes .= "\n\t" . $attributes_values['products_options_name'] . ' ' . $attributes_values['products_options_values_name'];

       }
     }
   }

I hope this gets it all working for you.

Carl B)

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