• Resolved onlinekey

    (@onlinekey)


    I want only the product ID to be sent to Paypal,

    not product title, how can I do that, please?

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Payment Plugins

    (@mrclayton)

    Hi @onlinekey

    You can use filter wc_ppcp_get_order_item to alter the information that’s sent to PayPal.

    Example: (adjust to suit your purposes)

    add_filter('wc_ppcp_get_order_item', function($item){
        $item->setName(null);
        $item->setDescription(null);
        return $item;
    });

    Kind Regards

    Thread Starter onlinekey

    (@onlinekey)

    where can i add the code please?

    Thread Starter onlinekey

    (@onlinekey)

    @mrclayton answer please

    How to use the filter? where i put the code?

    I put it on functions.php but dosent work.

    Plugin Author Payment Plugins

    (@mrclayton)

    That was an example snippet of code. Here is a tested snippet of code that’s been confirmed to work. You can modify this snippet further for more advanced scenarios.

    add_filter('wc_ppcp_get_order_item', function($item, $order_item){
        $item->setName($order_item->get_product_id());
        $item->setDescription(null);
        return $item;
    }, 10, 2);

    Rather than adding code to your theme’s functions.php, I recommend the following code snippet plugin. https://wordpress.org/plugins/code-snippets/

    Thread Starter onlinekey

    (@onlinekey)

    @mrclayton i put the code you give on plugin, i test an order but the product name still appears on PayPal.

    What i am missing? can you help, please

    Plugin Author Payment Plugins

    (@mrclayton)

    @onlinekey PayPal doesn’t allow the item name field to be empty, it’s a required field so there must be something there. That’s why in the example, the name is set to the product ID.

    If the item name field is blank, PayPal will fail the request because of their internal validations. So, you must put something there.

    Thanks

    Thread Starter onlinekey

    (@onlinekey)

    @mrclayton Please simplify, where to put the product name

    is it like this?

    Plugin Author Payment Plugins

    (@mrclayton)

    Please simplify, where to put the product name

    The example I provided already shows how to set the item’s name. $item->setName() and in the setName function you can add any non-empty value you want.

    Thread Starter onlinekey

    (@onlinekey)

    @mrclayton I tried several times but not sucuse
    Can you please give me a prebuilt code I want to put this name (Order145)

    Thread Starter onlinekey

    (@onlinekey)

    @mrclayton its working now thank you

    This is legit? paypal does not block for this changes?

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘hide product title on paypal’ is closed to new replies.