January 20, 2010 at 4:51 am #676
Loving the plugin – wonderfully simple…..so I thought I’d make it more difficult.
Basically, I want to drop [wp_cart:PRODUCT-NAME:price:PRODUCT-PRICE:end] in as a value in a custom field and have the Add to Cart button show up in a sidebar where the other related custom fields are displayed.
I figured out how to alter line 1451 to move the button to the excerpt
but I’d like to use the excerpt for something else…and excerpt.
Anyway to get the button in the sidebar?January 20, 2010 at 5:35 am #17385amin007Participant
You don’t need to change the line… you can just add the following line and it will filter the content as well as the excerpt:
To display a button on the sidebar use the following PHP function (you can pass in the product name and price to the function):
<?php echo print_wp_cart_button_for_product(“PRODUCT-NAME”, “PRODUCT-PRICE”); ?>January 20, 2010 at 7:06 pm #17386
Thanks! I finally got it to work!
1. I added the line you suggested to the wp_shopping_cart.php file.
2. In each post I added custom fields with the key/name Price & Shipping
3. In my sidebar template I established the 3 following variables
$prodname = $post->post_title ;
$prodprice = get_post_meta($post->ID, 'Price', true);
$prodshipping = get_post_meta($post->ID, 'Shipping', true);
4. Then added this line where I wanted to put the button in that same template file
<?php echo print_wp_cart_button_for_product($prodname, $prodprice, $prodshipping); ?>
This worked for me – I seriously doubt its totally correct by php or wordpress standards, so admin, feel free to correct.
Thanks again for a great and simple plugin.
KLMJanuary 20, 2010 at 8:23 pm #17387
Problem! Refreshing the page adds an item to the cart every time you refresh.
Any clues as to how this is happening?January 21, 2010 at 2:15 am #17388amin007Participant
When a HTTP POST operation is performed on a page (e.g add to cart operation) then refreshing the page right after that operation will repeat the same process thereby adding the same product again. This is why the browser gives you an warning when you refresh a page that is about to repeat an HTTP POST operation.
- You must be logged in to reply to this topic.