Tips and Tricks HQ Forum

Support Forum for Tips and Tricks HQ Products

Register or log in - lost password?

Search the Forum

Tips and Tricks HQ Forum » Simple PayPal Shopping Cart » Simple Shopping Cart Tweaks

"Add to Cart" button not in "the_content"

(5 posts) (2 voices)
  • Started 2 years ago by klmartin
  • Latest reply from amin007
  • Related Topics:
    1. Adding Simple Paypal to the Sidebar
    2. Mutiple Add to Cart Button Styles
    3. How to change position of Add to Cart Button
    4. Remove Add to Cart button in [wp_eStore_all_products_stylish:end] view
    5. Move "add to Cart Button" in [wp_eStore_fancy8 id=1]

Tags:

  • add to cart
  • custom fields
  • sidebar
  • the_content
  • the_excerpt
  1. 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?

    Posted 2 years ago #
  2. amin007
    Key Master

    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"); ?>

    Posted 2 years ago #
  3. 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

    Posted 2 years ago #
  4. klmartin
    Member

    Problem! Refreshing the page adds an item to the cart every time you refresh.
    Any clues as to how this is happening?

    Posted 2 years ago #
  5. amin007
    Key Master

    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.

    Posted 2 years ago #

RSS feed for this topic

Reply

You must log in to post.

Tips and Tricks HQ Forum is proudly powered by bbPress

Tips and Tricks HQ  | WP Shopping Cart  | WP Affiliate Software  | WordPress Membership Plugin