• I’m using WP Simple Paypal Cart and am trying to widgetize its code so that the ‘add to cart’ button pulls the post title into the ‘item name’ section of the code, and a custom field value into the price.

    I’ve got the first title part working, but when I inspect the page with firebug, it tells me that the price value is ‘Array’ (instead of the numeric string I’m expecting.) This sends the item to the cart with a $0 value.

    This is my code:

    <?php
    $productid = get_the_title();
    $amount = get_post_custom_values( 'item_price' );
    echo print_wp_cart_button_for_product("$productid", "$amount"); ?>

    My items have a custom field called ‘item_price’ with a number for the value. Why doesn’t this work?

    Here is an example of what I’m trying to do do: https://pins.kevinbyrd.co/ns0210/

    If someone could help me with this I’d be very grateful!

Viewing 1 replies (of 1 total)
  • Thread Starter Teratoma

    (@teratoma)

    I have solved this issue using the get-custom-field-values plugin.

    I’d still like to know if there’s a way to do it without it though.

Viewing 1 replies (of 1 total)
  • The topic ‘get_post_custom_values – what am I doing wrong?’ is closed to new replies.