Tips and Tricks HQ Support

Support site for Tips and Tricks HQ premium products

  • Home
  • Contact Us
  • Documentation
  • Forum Home
    • Forum
    • Forum Search
    • Forum Login
    • Forum Registration

"Add to Cart" button not in "the_content"

by

Tips and Tricks HQ Support Portal › Forums › Simple PayPal Shopping Cart › Simple Shopping Cart Tweaks › "Add to Cart" button not in "the_content"

Tagged: add to cart, custom fields, sidebar, the_content, the_excerpt

  • This topic has 4 replies, 2 voices, and was last updated 15 years, 3 months ago by amin007.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • January 20, 2010 at 4:51 am #676
    klmartin
    Member

    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

    ‘add_filter(‘the_content’, ‘print_wp_cart_button_new’,11);’

    to

    ‘add_filter(‘the_excerpt’, ‘print_wp_cart_button_new’,11);’

    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 #17385
    amin007
    Participant

    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:

    add_filter(‘the_excerpt’, ‘print_wp_cart_button_new’,11);

    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
    klmartin
    Member

    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

    <?php

    $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.

    KLM

    January 20, 2010 at 8:23 pm #17387
    klmartin
    Member

    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 #17388
    amin007
    Participant

    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.

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Log In

Forum Related

  • Forum Home
  • Forum Search
  • Forum Registration
  • Forum Login

Support Related Forms

  • Contact Us
  • Customer Support
  • Request a Plugin Update
  • Request Fresh Download Links

Useful Links

  • Plugin Upgrade Instructions
  • WP eStore Documentation
  • WP eMember Documentation
  • WP Affiliate Platform Documentation
  • Tips and Tricks HQ Home Page
  • Our Projects

Quick Setup Video Tutorials

  • WP eStore Video Tutorial
  • WP eMember Video Tutorial
  • WP Affiliate Platform Video Tutorial
  • Lightbox Ultimate Video Tutorial

Our Other Plugins

  • WP Express Checkout
  • Stripe Payments Plugin
  • Simple Shopping Cart Plugin
  • Simple Download Monitor

Copyright © 2025 | Tips and Tricks HQ