0

WC Stripe has an option where you can set it to 'capture immediately' or leave it unchecked for authorize payment only. I have left it checked by default, but there is a specific product category, where I dont want "Capture Immediately". How can I dynammically turn that off at the time of checkout with specific product with category in cart. I originally asked WooCommerce support but their response was a little over my knowledge over php and wordpress. I really appreciate all the help.

enter image description here

Response from WooCommerce Support

All settings of the Stripe plugin are filtered. Have a look at: /includes/settings-stripe.php - maybe you can leverage this.

Other than that take a look capture_payment() and how its hooked. You could try and add a conditional that unhooks this for your desired category.

URLs to the references:

/includes/settings-stripe.php

function: capture_payment()

0

in filtering one of the meta, you can stop capture depending of the order content

add_filter("get_post_metadata", function ($value, $object_id, $meta_key, $single) {


    if ("_stripe_charge_id" === $meta_key) {

        $order = wc_get_order($object_id);


        if (???) {
            // stop capture
            $value = FALSE;
        }

    }


    return $value;

}, 10, 4);
| improve this answer | |
  • Thank you! So I replace "if (???) {" with "if ( is_product() && has_term( 'Custom', 'product_cat' ) ) {" ? – user3137901 Oct 18 '17 at 17:43
  • MMM, sorry I am still an amateur, can you please help with the full code, if possible? Payment for any product having category "custom" should not be captured. – user3137901 Oct 18 '17 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.