Zen Cart Logo
Forums / General Questions / Adding a new radio button

Adding a new radio button

Views: 876

Results 1 to 4 of 4
21 Jan 2014, 10:24 AM
#1
kitten091182 avatar

kitten091182

Zen Follower

Join Date:
May 2007
Posts:
110
Plugin Contributions:
0

Adding a new radio button

Hi,
I have some products that can only be purchased online, not in store. As such I wanted to display an "Online Only" image on those product pages. Now, I have managed to add a (radio button) field to the database, get it to display in admin on the edit product page, get it to update the product and post it to the database, but I just can't get it to show on the product info page? It is a radio button selection, and you choose either yes or no for whether it is online only, it then posts 1 or 0 to the database. The code I have for the product_info template to display it is:

<!--bof Product is Online --> <?php if ($product_is_online != '1') { ?> <div id="productOnlineOnly" class="productGeneral"><?php echo OTHER_IMAGE_ONLINE_ONLY; ?></div> <?php } ?> <!--eof Product is Online -->

This displays the text OTHER_IMAGE_ONLINE_ONLY on all product pages regardless of the yes or no choice.
What am I doing wrong? I don't know too much about coding, I sort of copied the Call for Price function in Zen Cart and adapted it.
Any help would be greatly appreciated.

21 Jan 2014, 12:00 PM
#2
kitten091182 avatar

kitten091182

Zen Follower

Join Date:
May 2007
Posts:
110
Plugin Contributions:
0

Re: Adding a new radio button

It's ok, I missed something. In includes/modules/pages/product_info/main_template_vars.php I forgot to put:

$product_is_online = $product_info->fields['product_is_online'];

it works now

21 Jan 2014, 3:58 PM
#3
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Adding a new radio button

kitten091182:

It's ok, I missed something. In includes/modules/pages/product_info/main_template_vars.php I forgot to put:

$product_is_online = $product_info->fields['product_is_online'];

it works now

Sometimes just helps to "talk" it out. :)

Thing is though, are you still getting just a text of OTHER_IMAGE_ONLINE_ONLY when the image is supposed to be displayed? That is a define issue in that OTHER_IMAGE_ONLINE_ONLY was not set to anything before being displayed.

23 Jan 2014, 1:08 PM
#4
kitten091182 avatar

kitten091182

Zen Follower

Join Date:
May 2007
Posts:
110
Plugin Contributions:
0

Re: Adding a new radio button

mc12345678:

Sometimes just helps to "talk" it out. :)

Thing is though, are you still getting just a text of OTHER_IMAGE_ONLINE_ONLY when the image is supposed to be displayed? That is a define issue in that OTHER_IMAGE_ONLINE_ONLY was not set to anything before being displayed.

Hi,
I changed it to be:

<!--bof Product Is Online --> <?php if ($product_is_online == '1') { ?> <div id="productOnlineOnly" class="productGeneral"><?php echo zen_image($template->get_template_dir(OTHER_IMAGE_ONLINE_ONLY, DIR_WS_TEMPLATE, $current_page_base,'images'). '/' . OTHER_IMAGE_ONLINE_ONLY, ICON_IMAGE_TEXT); ?></div> <?php } ?>

And it works now.
It does help to talk it out lol