Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / Display Read Only attribute in cart

Display Read Only attribute in cart

Views: 11,924

Results 1 to 20 of 22
22 Mar 2010, 3:00 PM
#1
pjb923 avatar

pjb923

Zen Follower

Join Date:
Jan 2005
Location:
NY
Posts:
135
Plugin Contributions:
0

Display Read Only attribute in cart

I have a site where certain items need to have a note saying "Final Sale. This item cannot be returned."

This text needs to be visible not only on the product info page, but in the shopping cart and on the invoice. I thought the easiest way to handle this would be to create a "final sale" attribute.

Using the read only attribute, the text appears in the product info, but not in the attributes list when the item is added to the cart.

Does anyone know if it's possible to display it here?

22 Mar 2010, 6:10 PM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Display Read Only attribute in cart

Make it normal - required - selected

24 Mar 2010, 7:29 PM
#3
pjb923 avatar

pjb923

Zen Follower

Join Date:
Jan 2005
Location:
NY
Posts:
135
Plugin Contributions:
0

Re: Display Read Only attribute in cart

kobra:

Make it normal - required - selected

I tried that and it displays on the product info page, but I am still not seeing this attribute in the shopping cart.

I think it has something to do with the commented out code on the attributes module. Line 495 of attributes.php.

// Read Only - just for display purposes
                      if ($products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_READONLY) {
                        //            $tmp_html .= '<input type="hidden" name ="id[' . $products_options_names->fields['products_options_id'] . ']"' . '" value="' . stripslashes($products_options->fields['products_options_values_name']) . ' SELECTED' . '" />  ' . $products_options->fields['products_options_values_name'];
                        $tmp_html .= $products_options_details . '<br />';
                      } else {
                        $zv_display_select_option ++;
                      }

I tried playing around with this a little, but didn't get anywhere. Anything I touch on this line seems to cause problems with the display of the remaining attributes in the shopping cart, and causes the product image to disappear.

Do you have any other suggestions?

25 Mar 2010, 3:02 PM
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Display Read Only attribute in cart

I think it has something to do with the commented out code on the attributes module.
File path & file name?

3 Apr 2010, 2:13 PM
#5
pjb923 avatar

pjb923

Zen Follower

Join Date:
Jan 2005
Location:
NY
Posts:
135
Plugin Contributions:
0

Re: Display Read Only attribute in cart

kobra:

File path & file name?

includes/modules/attributes.php

It's actually line 486 in the default file. My attributes module did have other modifications, but reverting back to the default did not solve my problem.

3 Apr 2010, 3:11 PM
#6
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Display Read Only attribute in cart

If you make it a radiobutton type, default selected, it can't be unselected and will display in the cart. It would be possible to hide the select circle with CSS so that it would appear as straight text in the info page.

20 Apr 2011, 2:37 AM
#7
tthenne avatar

tthenne

New Zenner

Join Date:
Apr 2011
Posts:
38
Plugin Contributions:
0

Re: Display Read Only attribute in cart

I'm re-opening this thread because I'm still curious about this issue...so do the read-only attributes not show up in the cart?

kobra:

Make it normal - required - selected

^What does this mean? Make normal - required- is that still valid?

TH

20 Apr 2011, 3:28 AM
#8
tthenne avatar

tthenne

New Zenner

Join Date:
Apr 2011
Posts:
38
Plugin Contributions:
0

Re: Display Read Only attribute in cart

NVM I figured out the required setting (I think) this however does not affect "read-only" attributes.

gjh42:

If you make it a radiobutton type, default selected, it can't be unselected and will display in the cart. It would be possible to hide the select circle with CSS so that it would appear as straight text in the info page.

^
There has to be a better work around out there then to set an attribute to radio button and hide the button? Your product info page would still prompt the user to "please select" (or whatever your TEXT_PRODUCT_OPTIONS is defined as) and this could potentially confuse the user if there really is no selection option (as in a display only)

Here's my situation, maybe someone would be able to shine some light on it?
So I want to use the attributes as a tracking system (skew number). Yeah I could use the Model: as an SKU system but when I have more than one option for a product (ex. quantity) I have different SKUs for the different product options. I want to "pass" the SKUs on to my fulfillment company so I need the attribute to show up in the order (and in the order email). So as of what I know so far the "Read-Only" name option is out. The radio button-> default set is a decent work-around for single products, but I would imagine someone would be able to figure out a more optimal way? I have started looking at the tpl_modules_attributes.php file but I need to dig a little deeper it seems...looks like I should be going after the $zv_display_select_option variable or $options variable...does anyone know where to find these?

Any suggestions Anyone?

20 Apr 2011, 3:36 AM
#9
tthenne avatar

tthenne

New Zenner

Join Date:
Apr 2011
Posts:
38
Plugin Contributions:
0

Re: Display Read Only attribute in cart

tthenne:

looks like I should be going after the $zv_display_select_option variable or $options variable...does anyone know where to find these?

I found them...attributes.php in module directory

At least that's not a big file....:shocking:

20 Apr 2011, 4:13 AM
#10
tthenne avatar

tthenne

New Zenner

Join Date:
Apr 2011
Posts:
38
Plugin Contributions:
0

Re: Display Read Only attribute in cart

So I'm in my tpl_shopping_cart_default.php and I want to display the "read-only" attributes which up until now I have not got them to display.

Okay some of you big php gurus out there...walk me through this chunk of code so I can take a look at the attributes.php next

tpl_shopping_cart_default.php line: 89

<?php
  echo $product['attributeHiddenField'];
  if (isset($product['attributes']) && is_array($product['attributes'])) {
  echo '<div class="cartAttribsList">';
  echo '<ul>';
    reset($product['attributes']);
    foreach ($product['attributes'] as $option => $value) {
?>

<li><?php echo $value['products_options_name'] . TEXT_OPTION_DIVIDER . nl2br($value['products_options_values_name']); ?></li>

<?php
    }
  echo '</ul>';
  echo '</div>';
  }
?>

So I am understanding...the $product valuable is a big array, and the $product['attributeHiddenField'] looks like it is our product id (going to be sent on in the form), and then we have our conditional...if the attributes field is set and $products['attributes'] is an array echo our divs. Then we reset the $products['attributes'] so we're going to the first value of the $products['attributes'] array and we are setting our keys to $value array. Then we are echoing out the product_options_name (ex. quantity) and then we have our divider and then and then a br / and our products_options_values_name (ex. 100 count)

So the question arises...why wouldn't it echo out a "read-only" product attribute???

20 Apr 2011, 4:35 AM
#11
tthenne avatar

tthenne

New Zenner

Join Date:
Apr 2011
Posts:
38
Plugin Contributions:
0

Re: Display Read Only attribute in cart

tthenne:

Yeah I could use the Model: as an SKU system

^Check that...It doesn't look like the Model # gets carried into the shopping cart either, which makes me wonder if it gets processed on the orders/email/invoice...anyone know?

20 Apr 2011, 5:59 AM
#12
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Display Read Only attribute in cart

The model number does get displayed in the confirmation e-mail at least.

20 Apr 2011, 12:57 PM
#13
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Display Read Only attribute in cart

The Read Only Attributes were designed specifically to not be part of the cart ... they are just there for display ...

They only display on the product _info page but are never included in the cart when the Product is added ...

These Read Only Attributes make a handy way to have a display of information on multiple Products that read the Attribute as text ... then, if that text needs to be changed, it can be changed once and reflect that change on all Products that use them ...

20 Apr 2011, 1:35 PM
#14
tthenne avatar

tthenne

New Zenner

Join Date:
Apr 2011
Posts:
38
Plugin Contributions:
0

Re: Display Read Only attribute in cart

gjh42:

The model number does get displayed in the confirmation e-mail at least.

Well the model number will work for certain items...however, I don't believe you can change the model number with the attributes unless you maybe use some javascript to "listen" for the change in the radio button, drop-down or check-box. What I've done so far is I've included the SKU as part of the option value. So for instance, if the customer chooses the quantity ->100 count SKU 5454 or the quantity->200 count SKU 5555 . However, it would be nice if I could have the SKU as a separate attribute to the product; and this is where the read only comes in as I would not want my customers "selecting" the SKU.

I realize that the read-only attributes are for display purposes and are handy to display 1 or 2 messages on many products. However, there just has to be a way that they will display on the confirmation email or in the shopping cart. I still don't quiet understand why it wouldn't display if it is looping through the $product['attributes'] array...the "reaad-only" attributes have to be stored somewhere in that field?

TH

20 Apr 2011, 2:47 PM
#15
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Display Read Only attribute in cart

A read-only attribute will not get you a bit nearer to reflecting the real attributes selected by the customer. The model number is at least processed through already, though I doubt it is feasible to change that on the fly per order, since it is in the db. I think what you would want is code that would take the attribute id on order submission and display the corresponding SKU in certain places (shopping cart, order confirmation...).

Does each attribute have a full SKU, or is the variant SKU composed of base + attribute values? Do you have multiple attributes on products, such that a product with A1 and B3 is different from one with A1 and B2?

20 Apr 2011, 2:55 PM
#16
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Display Read Only attribute in cart

The Stock by Attributes mod might help you distinguish these, though it doesn't have SKU by attribute. I have heard talk of people trying to implement that, but no reports of success. No matter what, for a robust implementation of SKU by attribute, you will need a new database table or field(s) relating product id, attribute id(s) and SKUs.

20 Apr 2011, 6:02 PM
#17
tthenne avatar

tthenne

New Zenner

Join Date:
Apr 2011
Posts:
38
Plugin Contributions:
0

Re: Display Read Only attribute in cart

gjh42:

I think what you would want is code that would take the attribute id on order submission and display the corresponding SKU in certain places (shopping cart, order confirmation...)

^I think you are right. So what you are saying is that each attribute that you have has it's own record in the database. So therefore, I could specify that each attribute that I apply to the product would have it's own $product['attribute_sku'] field and I would then be able to display that in certain places (including the confirmation email)??

This seems like it would involve a wee bit of coding and I haven't taken too close of a look at the orders.php file (which is where this would have to be done). furthermore, to make it user-friendly I would have to familiarize myself with the admin side so I can submit the SKU to the database and assign it to it's $products['attribute_sku'] field.

Anyone love coding a nice little plugin??? :D

Does each attribute have a full SKU, or is the variant SKU composed of base + attribute values? Do you have multiple attributes on products, such that a product with A1 and B3 is different from one with A1 and B2?

^Yes each attribute has a full unique SKU. I don't have multiple attributes as of right now. Here is my exact situation. So for product A you can order different amounts(quantity) so I called this attribute Quantity. Now there is a 90 count (Quantity value) and a 180 count (Quantity value). If you select Product A, 90 count (SKU: 4545) you would be selecting a different SKU than if you selected Product A, 180 count (SKU: 5555)

20 Apr 2011, 9:46 PM
#18
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Display Read Only attribute in cart

Too bad... it would make it easy if the SKU for the product with attribute could be built from base product SKU + attribute SKU fragment.

Each option name and each option value has its own id, and when one of these values is applied to a particular product, it acquires its own unique attribute id (which would be stored in the db, keyed to product, option name and option value). You could add a new field to that table for attribute_sku, and the required code to insert it from admin and retrieve it for display/use.

Inserting would probably best be done in the Attributes Controller.

20 Apr 2011, 9:51 PM
#19
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Display Read Only attribute in cart

You might create a function like get_attribute_sku_from_id($attrib_id) so that you could just call this from any place you need to use it.
$attrib_id will be available wherever the order is being handled.
Or maybe you could change the core lookups to retrieve attribute_sku when attribute_id is being fetched.

21 Apr 2011, 4:03 PM
#20
tthenne avatar

tthenne

New Zenner

Join Date:
Apr 2011
Posts:
38
Plugin Contributions:
0

Re: Display Read Only attribute in cart

gjh42:

You could add a new field to that table for attribute_sku, and the required code to insert it from admin and retrieve it for display/use.

Which table are you referring to?

The products_attribute table I'm assuming.

So I'm still curious how this function would look. When you create an product option that goes into the product_options table
and when you assign a option value to that it goes into the product_options_values table

When you assign an product option and a product option value to a particular product that becomes an attribute and gets it's own unique record in the products_attribute table

so what you are saying is that since each product attribute has it's own unique attribute_id you could create another field that stores the attributes_sku in that table. Then when you wanted to pull out the SKU for a product you could call the unique attribute_id and filter out the attributes_sku?

The attribute_sku value would all be controlled within the attributes_controller.php and you would call to it in orders.php?