Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › Displaying 'Add to Cart' button on product list page
Tagged: add to cart button
- This topic has 3 replies, 2 voices, and was last updated 14 years, 2 months ago by
admin.
-
AuthorPosts
-
August 30, 2011 at 4:55 pm #4188
dangermoose
SpectatorHi there,
You helped me out before with a similar problem I was having and for some reason even though I’ve set this site up in the same way, I can’t get the add the cart buttons to display on the page that lists all products. (It displays fine in the individual product page)
Currently getting the error ‘Looks like you have entered a product ID () in the shortcode that doesn’t exist. Please check your product ID and the shortcode again!’
The code in my template:
<div id="productId">
<p>
<?php
$values = get_post_custom_values('product_id');
echo get_button_code_for_product($values[0]);
?>
</p>
</div>The shortcode in the page:
[wp_eStore:product_id:1:end]I might be missing something obvious!
August 31, 2011 at 1:30 am #36010admin
KeymasterWell it’s simple, when you call this function you need to make sure you are providing a valid Product ID:
get_button_code_for_productOn this page (where you are having the issue)… the custom field value is wrong (it needs to be a valid product ID. WP eStore can’t display a button for a product if it doesn’t know which product to look for.
September 14, 2011 at 1:55 pm #36011dangermoose
SpectatorHi there,
I’ve checked the custom field value & it’s definately correct, but still no luck. I’ve only got one product for testing at the minute so the value is simply ‘1’.
I think it might have something to do with the fact that the shortcodes are placed in pages and not posts – do you think this is possible and might cause issues.
get_post_custom_valuesI’m guesssing this is designed to pull values from posts – not pages?
Thanks in advance!
d.
September 14, 2011 at 11:34 pm #36012admin
KeymasterThere is an easy way to test it out. Simply echo the value of the customer field that your are retrieving by doing the following:
<?php
$values = get_post_custom_values('product_id');
echo "Custom field value: ".$values[0];
echo get_button_code_for_product($values[0]);
?>This will tell you if you are really passing “1” to the eStore function or something else. I can guarantee you that eStore is not receiving a plain “1” there.
-
AuthorPosts
- You must be logged in to reply to this topic.