Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter jmgeffroy

    (@jmgeffroy)

    I thought I had found the solution. I was using the wrong filter. Thanks to https://docs.paymentplugins.com/wc-stripe/api/source-class-WC_Stripe_Payment.html#259, I noticed that I should use 'wc_stripe_order_meta_data':

    add_filter( 'wc_stripe_order_meta_data', 'add_custom_stripe_metadata', 50, 2 );

    function add_custom_stripe_metadata( $metadata, $order) {
    ...
    return $metadata;
    }

    However, for some unknown reason, this filter is not called. But it should, as I read in the aforementioned documentation:

    $args['metadata'] = apply_filters( 'wc_stripe_order_meta_data', $meta_data, $order );

    Perplexed…

    Plugin Author Clayton R

    (@mrclayton)

    Hi @jmgeffroy

    The filter wc_stripe_order_meta_data is called. Typically when custom code is not being called, it’s because the the add_filter is being called used in an incorrect sequence. I would recommend something like:

    add_action('init', function(){
    add_filter('wc_stripe_order_meta_data', 'add_custom_stripe_metadata', 50, 2);
    });

    Kind Regards

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Can’t add custom metadata’ is closed to new replies.