If this is your first visit, check our documentation. To post, register or login.
Forums / Templates, Stylesheets, Page Layout / I would like to restrict cart image to products with no attributes

I would like to restrict cart image to products with no attributes

Started by member on 25 Mar 2011, 4:55 PM · Views: 889

Results 1 to 6 of 6
25 Mar 2011, 4:55 PM
#1
member avatar

member

Zen Follower

Join Date:
Dec 2004
Posts:
102
Plugin Contributions:
0

I would like to restrict cart image to products with no attributes

I have been sucessfully using the information in post #8
http://www.zen-cart.com/forum/showthread.php?t=74524
to show the correct attribute image in my cart. I have configuration>images>Image - Shopping Cart Status
set to 0 (if I turn it on I get two images on a product that has attributes, the main product image and the attribute image)

I need to know how to allow the main product image only if there are no attributes involved with the product.

I can turn the switch back on if there is a way to stop showing the main image IF there is an attribute.

Otherwise I can leave the switch off and put the appropriate code in the correct file, I suspect this would be the tpl_shopping_cart_default.php file.

Can anyone suggest an if type statement that I can use and possibly where in the code I would need to put it to restrict the main product image shown in the cart to only be rendered if there are no attributes involved with the product.

Thanks for any help you can offer.

26 Mar 2011, 12:32 AM
#2
celtic avatar

celtic

Zen Follower

Join Date:
Feb 2010
Posts:
154
Plugin Contributions:
0

Re: I would like to restrict cart image to products with no attributes

You could try this instead of the last line suggested in post #8 in the other thread...

<li><?php echo $value['products_options_name'] . TEXT_OPTION_DIVIDER . ($value['attributes_image']=="")? zen_image(DIR_WS_IMAGES . $product['productsImage']) : zen_image(DIR_WS_IMAGES . $value['attributes_image']); ?></li>

Here's the code block...

<li><?php echo $value['products_options_name'] . TEXT_OPTION_DIVIDER . ($value['attributes_image']=="")? zen_image(DIR_WS_IMAGES . $product['productsImage']) :  zen_image(DIR_WS_IMAGES . $value['attributes_image']); ?></li>

I've no idea if this will work as I don't have attributes to test it with, but it basically checks to see if an attribute_image has been specified. If it hasn't then it tries to display the main productsImage instead.

27 Mar 2011, 5:03 PM
#3
member avatar

member

Zen Follower

Join Date:
Dec 2004
Posts:
102
Plugin Contributions:
0

Re: I would like to restrict cart image to products with no attributes

Thanks, but that just causes the main picture to still exist and my attribute image to be a red x.

I am actually using this:

<?php echo nl2br($value['products_options_values_name'] . '<br /><br />' . TEXT_OPTION_DIVIDER . zen_image(DIR_WS_IMAGES . $value['attributes_image'])); ?>

instead of :

<li><?php echo $value['products_options_name'] . TEXT_OPTION_DIVIDER . zen_image(DIR_WS_IMAGES . $value['attributes_image']); ?></li>

The differences on that are irrelevant as far as the images are concerned.

28 Mar 2011, 8:11 PM
#4
celtic avatar

celtic

Zen Follower

Join Date:
Feb 2010
Posts:
154
Plugin Contributions:
0

Re: I would like to restrict cart image to products with no attributes

Try this line instead, I had the close bracket in the wrong place in my original post...

<li><?php echo $value['products_options_name'] . TEXT_OPTION_DIVIDER . ($value['attributes_image']=="" ? zen_image(DIR_WS_IMAGES . $product['productsImage']) :  zen_image(DIR_WS_IMAGES . $value['attributes_image'])); ?></li>
28 Mar 2011, 8:57 PM
#5
member avatar

member

Zen Follower

Join Date:
Dec 2004
Posts:
102
Plugin Contributions:
0

Re: I would like to restrict cart image to products with no attributes

I am sorry I did not see what you posted until now. I will save this post so I can try the syntax if something similar comes up again. I appreciate your help very much.

I had already ended up changing the file a lot by using the information in post 7 here http://www.zen-cart.com/forum/showthread.php?t=138054&highlight=attribute+image+shopping+cart

To anyone with this issue please note I had to remove a ?> to get it to work due to my products with attributes stock add on. I was more or less there twice.

30 Aug 2011, 5:37 AM
#6
webstar59 avatar

webstar59

New Zenner

Join Date:
Jun 2011
Location:
California
Posts:
63
Plugin Contributions:
0

Re: I would like to restrict cart image to products with no attributes

The post 7 http://www.zen-cart.com/forum/showthread.php?t=138054&highlight=attribute+image+shopping+cart has an error at the line 89 part. It should be as the fallowing script

<?php
if (isset($product['attributes']) && is_array($product['attributes'])) {
echo '';}else{
echo '<span id="cartImage" class="back">'.$product['productsImage'].'</span>';} ?>