- This topic has 2 replies, 2 voices, and was last updated 14 years, 10 months ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.
Support site for Tips and Tricks HQ premium products
by
Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › WP eStore Troubleshooting › Problems adding "Add to Cart" on index.php using Custom Fields
Tagged: custom fields
I hope someone can help me, I am wasted so much time already trying to get this to work!
(Disclaimer: I am new to PHP but understand just enough to get by…so please bear with me.)
Basically here’s what I want:
– An “Add to Cart” button for each product on my index.php, the product number I want called from a Custom Field.
Here is the code I am currently using:
<?php echo get_button_code_for_product(“<?php $values = get_post_custom_values(‘prodid’); echo $values[0]; ?>”); ?>
So the Add to Cart button shows up, but when you click it a blank item is added to the cart on the right hand side with the right price but no title. When you go to checkout it says the cart is empty.
I haven’t modified the WP E Store plugin at all and being that the button is showing but not working right I must be doing something wrong.
Please help? My website is http://niftywebstuff.com
@bballa, The PHP code you have cooked up is no good. Please note that this is no way possible for us to teach you PHP programming language here. You should maybe look at the official site for PHP and see if they have any forum for this.
with that said, here is the method signature of the function that you are trying to call:
function get_button_code_for_product($id)
the “get_button_code_for_product” method takes one parameter and that is the ID of the product that you are trying to show the button for. So all you need to do is pull the product ID from the custom field and pass it to this function. You can try something like the following:
<?php
$values = get_post_custom_values('prodid');
echo get_button_code_for_product($values[0]);
?>
Just a note… the above code hasn’t been tested.
That worked –
Thanks so much for your help – I will be sure to keep the PHP website handy for future code issues.
Thanks again!