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

Get PRODUCT NAME from title attribute and PRICE from custom field?

by

Tips and Tricks HQ Support Portal › Forums › Simple PayPal Shopping Cart › Simple Shopping Cart Tweaks › Get PRODUCT NAME from title attribute and PRICE from custom field?

Tagged: costum post type, custom field, name, price

  • This topic has 2 replies, 2 voices, and was last updated 12 years, 8 months ago by nicoleg.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • July 2, 2010 at 2:27 pm #1442
    nicoleg
    Member

    I’m creating an art store using a Custom Post type and a custom field to handle the price. What I would like to do is use this code to create the “add to cart” button in the store’s template:

    <?php echo print_wp_cart_button_for_product(’PRODUCT-NAME’, PRODUCT-PRICE); ?>

    Using this code, is there a way to pull the product name from the title of the post and the price from the custom field? Is there any other way to achieve this? I’m running this store with several other artists who are not code-savvy, so to speak, so I’m trying to avoid them having to use the shortcode when they add an item.

    July 3, 2010 at 12:29 am #22173
    amin007
    Participant

    Yeah, you should be able to do it. This post should help you with getting the custom field information:

    coding question for simple cart wp plugin with custom field template plugin

    Given that you are calling that function form the WordPress loop you can use the following code to get the title of the post:

    <?php
    $title = the_title();
    echo print_wp_cart_button_for_product($title,"15.95");
    ?>

    You can also query WordPress to get the information of an individual post from anywhere on your blog. This post has more info on this:

    http://www.tipsandtricks-hq.com/query-or-show-a-specific-post-in-wordpress-php-code-example-44

    July 3, 2010 at 5:26 pm #22174
    nicoleg
    Member

    Thanks! That first link did exactly what I was looking for.

  • 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 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
  • WP PDF Stamper Documentation
  • WP Photo Seller 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
  • WP Photo Seller Video Tutorial

Our Other Plugins

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

Copyright © 2023 | Tips and Tricks HQ