• Resolved sopaitun

    (@sopaitun)


    Hi there,

    I saw in the document that this plugin will collect metadata which include product name ( $product = $item->get_product ();)
    Is there any way to disable this. Can I delete this code line directly in php file or use any hook.
    Please help.

    Thank you.

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

    (@mrclayton)

    Hi @sopaitun

    You can use the hook wc_stripe_order_meta_data and unset the entries that contain the product data.

    https://docs.paymentplugins.com/wc-stripe/api/source-class-WC_Stripe_Payment.html#168-180

    Kind regards

    Thread Starter sopaitun

    (@sopaitun)

    Hi @mrclayton

    I tried to add these codes below to function file of pl;ugin:

    function add_order_meta_data($meta_data, $order) {
        $meta_data[ 'product_' . $product->get_id () ] = sprintf ( '%s x %s', $product->get_order_identifier (), $item->get_quantity () );
        return $meta_data;
    }
    
    add_filter ( 'wc_stripe_order_meta_data', 'add_order_meta_data', 10, 2 );

    However these codes made plugin not work anymore.
    Please help

    Plugin Author Payment Plugins

    (@mrclayton)

    Hi @sopaitun that’s because yo are using a variable $product that is not defined anywhere so it’s going to cause a php error.

    Kind Regards,

    Thread Starter sopaitun

    (@sopaitun)

    @mrclayton

    I tried add this in theme’s function file:

    function pbn_add_order_meta_data($meta_data, $order) {
        foreach ( $order->get_items ( 'line_item' ) as $item ) {
            /**
             *
             * @var WC_Order_Item_Product $item
             */
            $product = $item->get_product ();
            $meta_data[ 'product_' . $product->get_id () ] = sprintf ( '%s x %s', $product->get_id (), $item->get_quantity () );
        }
        return $meta_data;
    }
    
    add_filter ( 'wc_stripe_order_meta_data', 'pbn_add_order_meta_data', 10, 2 );

    It worked at 1st time. However when I update or re-active plugin, it just add more line in metadata instead of changing metadata.
    All I want is not showing product name in metadata. Please help

    Plugin Author Payment Plugins

    (@mrclayton)

    @sopaitun if you don’t want to show the product name in the metadata then you need to remove the entry from the metadata array.

    I recommend you lookup how to unset array entries using PHP.

    Kind Regards,

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Do not Get product name in metadata’ is closed to new replies.