I am trying to have radio buttons for product size options with different prices and names.

davidzupecdavidzupec Member
in Help edited November 2013
Hello all, when you check one of the product sizes, ie: Dainty .75, Dainty 1, Chunk 1.5, Chunk 2, etc., and click the Add To Cart button, Foxycart grabs the size option name but not the price. I can't figure out how to get that to work. Any ideas anyone : ) Below is my html code I have and my link to the website to see it: http://lemajdesign.com/product/solid/
<table>																						
	<?php if( get_field('dainty_size_1') && get_field('dainty_size_2')): ?><!-- If there is a Dainty size -->
											
		<tr class="dainty">	  
			<td><input type="radio" class="radio" name="size" value="Dainty .75" /><label class="label_right"><?php the_field('dainty_size_1'); ?></label></td>  
			<td class="price"><?php the_field('dainty_size1_price'); ?></td>
		</tr>
											
		<tr class="dainty">
			<td><input type="radio" class="radio" name="size" value="Dainty 1" /><label class="label_right"><?php the_field('dainty_size_2'); ?></label></td>  
			<td class="price"><?php the_field('dainty_size2_price'); ?></td>		
		</tr>
										
	<?php endif; ?><!-- End Dainty size -->								
										
	<?php if( get_field('chunk_size_1') && get_field('chunk_size_2')): ?><!-- If there is a Chunk size -->
											
		<tr class="chunk">
			<td><input type="radio" class="radio" name="size" value="Chunk 1.5" /><label class="label_right"><?php the_field('chunk_size_1'); ?></label> </td>
			<td class="price"><?php the_field('chunk_size1_price'); ?></td>
		</tr>
											
		<tr class="chunk">
			<td><input type="radio" class="radio" name="size" value="Chunk 2" /><label class="label_right"><?php the_field('chunk_size_2'); ?></label></td>
			<td class="price"><?php the_field('chunk_size2_price'); ?></td>
		</tr>
										
	<?php endif; ?><!-- End Chunk size -->
										
	<?php if( get_field('big_mama_size_1') && get_field('big_mama_size_2')): ?><!-- If there is a Big Mama size -->
											
		<tr class="bigmama">
			<td><input type="radio" class="radio" name="size" value="Big Mama 2.5" /><label class="label_right"><?php the_field('big_mama_size_1'); ?></label></td>
			<td class="price"><?php the_field('big_mama_size1_price'); ?></td>
		</tr>
											
		<tr class="bigmama">
			<td><input type="radio" class="radio" name="size" value="Big Mama 3" /><label class="label_right"><?php the_field('big_mama_size_2'); ?></label></td>
			<td class="price"><?php the_field('big_mama_size2_price'); ?></td>
		</tr>



Tagged:
Comments
  • fc_adamfc_adam FoxyCart Team
    @davidzupec,

    What you're needing there is 'product option modifiers' which allows you to modify a products price, weight, code and category via inputs in an add to cart form. You can see information on them at the bottom of this page: http://wiki.foxycart.com/static/redirect/add_to_cart
  • Hello fc_adam,

    Thank you, I was introduced to those the other day and have been pulling my hair out trying to figure it out ever since, but unfortunately with no success. I'm kinda down to the wire here, Is there anyone you could recommend that could help me out with this?

    Thank you,

    David
  • fc_adamfc_adam FoxyCart Team
    edited November 2013
    Taking your code from above, the last table row would look like this:
    <tr class="bigmama">
      <td><input type="radio" class="radio" name="size" value="Big Mama 3{p:<?php the_field('big_mama_size2_price'); ?>}" /><label class="label_right"><?php the_field('big_mama_size_2'); ?></label></td>
      <td class="price"><?php the_field('big_mama_size2_price'); ?></td>
    </tr>
    

    So if the price for Big Mama 3 was $5, the radio input would have a value of:
    Big Mama 3{p:5}
    

    Which says that the size value for the product would be "Big Mama 3", and the price would be set to $5, no matter what the hidden price input has set.

    I'll whisper you our recommended developers list in case you'd like some more one-on-one assistance with this.
  • Hi Adam,

    Thank you for giving me some direction with your code above. Tomorrow I'm going to try and tackle this myself first to see if I can get it, especially since I have another website similar to this coming up next. If all else fails I'll try and contact one of those devs.

    Thank you again I appreciate it! : )
  • Hi Adam, using your example, this is the code I have for the Big Mama and when add to cart is clicked it's showing a price of $0. I can't figure out what I'm doing wrong! Below is what I have:
    <input type="hidden" name="price" value="{p:<?php the_field('big_mama_size2_price'); ?>}" />
    											
    	<tr class="bigmama">
    		<td><input type="radio" class="radio" name="size" value="Big Mama 3{p:<?php the_field('big_mama_size2_price'); ?>}" /><label class="label_right"><?php the_field('big_mama_size_2'); ?></label></td>
    		<td class="price"><?php the_field('big_mama_size2_price'); ?></td>
             </tr>
    
  • Weird, Also I just discovered that the Big Mama price shows up on all the other sizes except for the one it's intended for. For example when I click the "Dainty 1" size option it records the Big Mama pricing?
  • fc_adamfc_adam FoxyCart Team
    @davidzupec,

    Do you have this page online somewhere that we could see what's being output by your PHP page?
  • Hi Adam, it's solved : ) I had contacted one of the devs that you recommended! Thank you again for your help.

    David
  • fc_adamfc_adam FoxyCart Team
    @davidzupec,

    Awesome! Thanks for updating us
Sign In or Register to comment.