gearup Posted September 22, 2012 Share Posted September 22, 2012 Hi, I am adding a product by default to each order so it will always appear in the shopping cart. What I am trying to achieve is for this product the Quantity remains set at 1 (eg read only). I have added some php to the cart body htm file and I now get 2 columns for quantity, one read only and the other is editable (I know this is an error but...). I know the ID for this product (39) but seem unable to get the conditional code to detect the ID and just set that specific one to read only. can someone please tell me what is wrong here? Here is the htm code, original, <tr><td class="mod_bakery_cart_td_thumb_f"><a href="{LINK}"><img src="{THUMB_URL}" alt="{NAME}" width="{THUMB_WIDTH}" height="{THUMB_HEIGHT}" border="0" /></a></td><td class="mod_bakery_cart_td_sku_f">{SKU}</td><td class="mod_bakery_cart_td_name_f"><span class="mod_bakery_cart_item_f">{NAME}</span><br />{ATTRIBUTE}</td><td class="mod_bakery_cart_td_quantity_f"><input type="text" name="quantity[{ITEM_ID}][{ATTRIBUTES}]" value="{QUANTITY}" id="id_{ITEM_ID}_{ATTRIBUTES}" style="text-align: right" size="4" /> <a href="#" onclick="javascript: mod_bakery_delete_item_f('{ITEM_ID}_{ATTRIBUTES}');"> <img src="{WB_URL}/modules/bakery/images/delete.gif" alt="{TEXT_DELETE}" title="{TEXT_DELETE}" /></a></td><td class="mod_bakery_cart_td_price_f">{PRICE}</td><td class="mod_bakery_cart_td_shipping_f" style="display: {DISPLAY_SHIPPING}">{SHIPPING}</td><td class="mod_bakery_cart_td_sum_f">{TOTAL}</td></tr> and now changed by me, <tr><td class="mod_bakery_cart_td_thumb_f"><a href="{LINK}"><img src="{THUMB_URL}" alt="{NAME}" width="{THUMB_WIDTH}" height="{THUMB_HEIGHT}" border="0" /></a></td><td class="mod_bakery_cart_td_sku_f">{SKU}</td><td class="mod_bakery_cart_td_name_f"><span class="mod_bakery_cart_item_f">{NAME}</span><br />{ATTRIBUTE}</td><td class="mod_bakery_cart_td_quantity_f" id="{ITEM_ID}" $id-xx = id> <?php if $id-xx == 39): ?> <input type="text" name="quantity[{ITEM_ID}][{ATTRIBUTES}]" readonly="readonly" value="{QUANTITY}" id="id_{ITEM_ID}_{ATTRIBUTES}" style="text-align: right" size="4" /> <?php else: ?> <input type="text" name="quantity[{ITEM_ID}][{ATTRIBUTES}]" value="{QUANTITY}" id="id_{ITEM_ID}_{ATTRIBUTES}" style="text-align: right" size="4" /> <a href="#" onclick="javascript: mod_bakery_delete_item_f('{ITEM_ID}_{ATTRIBUTES}');"> <img src="{WB_URL}/modules/bakery/images/delete.gif" alt="{TEXT_DELETE}" title="{TEXT_DELETE}" /></a> <?php endif; ?></td><td class="mod_bakery_cart_td_price_f">{PRICE}</td><td class="mod_bakery_cart_td_shipping_f" style="display: {DISPLAY_SHIPPING}">{SHIPPING}</td><td class="mod_bakery_cart_td_sum_f">{TOTAL}</td></tr> I think my problem is with passing a value into the php section but someone else may have a better idea. Regards, Link to comment Share on other sites More sharing options...
niche Posted September 23, 2012 Share Posted September 23, 2012 What php errors are you getting if any? Link to comment Share on other sites More sharing options...
niche Posted September 23, 2012 Share Posted September 23, 2012 (edited) Your $id-xx variable is a problem also. I don't know why, but a hyphen in a variable produces a parse error for me. I'm sure someone will post the reason. Here's the script that produced a parse error for me. <?php$id-xx = 39;echo $id-xx;?> Edited September 23, 2012 by niche Link to comment Share on other sites More sharing options...
Don E Posted September 23, 2012 Share Posted September 23, 2012 (edited) What's going on here: <td class="mod_bakery_cart_td_quantity_f" id="{ITEM_ID}" $id-xx = id> The if condition doesn't look right.. did you mean something like this: <?php if($id-xx == 39) { ?> <input type="text" name="quantity[{ITEM_ID}][{ATTRIBUTES}]" readonly="readonly" value="{QUANTITY}" id="id_{ITEM_ID}_{ATTRIBUTES}" style="text-align: right" size="4" /> <?php }else{ ?> <input type="text" name="quantity[{ITEM_ID}][{ATTRIBUTES}]" value="{QUANTITY}" id="id_{ITEM_ID}_{ATTRIBUTES}" style="text-align: right" size="4" /> <a href="#" onclick="javascript: mod_bakery_delete_item_f('{ITEM_ID}_{ATTRIBUTES}');"> <img src="{WB_URL}/modules/bakery/images/delete.gif" alt="{TEXT_DELETE}" title="{TEXT_DELETE}" /></a> <?php } ?> Are you working with some kind of template system by any chance? Edited September 23, 2012 by Don E Link to comment Share on other sites More sharing options...
gearup Posted September 23, 2012 Author Share Posted September 23, 2012 (edited) Hi and thanks for the input, Yes, I am using a template system but the problem appears to be that I was trying to add php code into a .htm file. I had some support from a friend who suggested I should do the conditional test in the .php file where the variables are defined such as; $read_txt = ($items[$i]['item_id'] == "39") ? 'readonly="readonly"' : ''; .... 'READONLY' => $read_txt then in the .htm file use, ...<td class="mod_bakery_cart_td_quantity_f"><input type="text" name="quantity[{ITEM_ID}][{ATTRIBUTES}]" {READONLY} value="{QUANTITY}" id="id_{ITEM_ID}_{ATTRIBUTES}" style="text-align: right" size="4" /> <a href="#" onclick="javascript: mod_bakery_delete_item_f('{ITEM_ID}_{ATTRIBUTES}');"> <img src="{WB_URL}/modules/bakery/images/delete.gif" alt="{TEXT_DELETE}" title="{TEXT_DELETE}" /></a></td>... I tried this and it works. There is always something to learn with coding Regards, Edited September 23, 2012 by gearup Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now