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

Problems adding "Add to Cart" on index.php using Custom Fields

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

  • This topic has 2 replies, 2 voices, and was last updated 15 years, 4 months ago by Brian.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • January 11, 2010 at 10:19 pm #376
    Brian
    Spectator

    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

    January 12, 2010 at 12:45 am #17167
    amin007
    Participant

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

    January 12, 2010 at 1:14 am #17168
    Brian
    Spectator

    That worked –

    Thanks so much for your help – I will be sure to keep the PHP website handy for future code issues.

    Thanks again!

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 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