• Resolved apaimagixdk

    (@apaimagixdk)


    Hi,

    I want to automaticly insert the current post title into this line where it says PRODUCT-NAME… (in single.php)

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

    It’s probably simple but i am no good with php.

    Hope somebody can help me?

    Regards,
    Anders

Viewing 4 replies - 1 through 4 (of 4 total)
  • MichaelH

    (@michaelh)

    Should be able to replace ‘PRODUCT-NAME’ with $post->post_title as long as that code is in a post loop.

    Thread Starter apaimagixdk

    (@apaimagixdk)

    It works. Thanks! You dont want to know how much time i spent trying to figure it out by myself!

    This is a variation on that question, but definitely related… in the same cart plugin, how could you get the data from a custom field that contains the product name and price into the cart button template code? For example, the cart uses:

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

    and the info I want is stored in custom field keys “MMTname” and “MMTprice”…. I am already displaying this data (and more) from custom fields in the same page.

    Help greatly appreciated!

    Nevermind… going on what was suggested above, I put the custom field data into $vars like:

    $prodname = c2c_get_custom('MMTname');
    $prodprice = c2c_get_custom('MMTprice');

    and then later, when calling the cart button, used them, like so:

    <?php echo print_wp_cart_button_for_product($prodname, $prodprice); ?>

    Thanks for pointing me in the right direction!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Inserting the_title() into a function?’ is closed to new replies.