No products in the cart.
- This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
December 14, 2023 at 7:12 am #9921loictheaztecParticipant
You can try the following for Cash on delivery (COD) payment method, replacing in the code both
'my_variable'
with the correct slug:add_filter( 'woocommerce_cod_process_payment_order_status', 'conditionally_change_cod_order_status_to_pending', 10, 2 ); function conditionally_change_cod_order_status_to_pending( $status, $order ) { $global_var = $GLOBALS; if ( isset($global_var['my_variable']) && $global_var['my_variable'] ) { return 'pending'; } return $status; }
Code goes in functions.php file of your child theme (or in a plugin). It should work.
December 14, 2023 at 10:29 am #9920alenchParticipantI tried many scenarios and hooks and at the end even in child template file for thankyou page
So if order is not failed and global variable == true switch to pending:
<?php if ($order->has_status('failed')) : ?> //code <?php else : ?> <?php if ($GLOBALS['variable'] == true) : ?> <?php $order->update_status('pending'); ?> <?php endif; ?>
Status is changing but the problem is that it is going from processing to pending. How to prevent going to processing status if condition ($GLOBALS[‘variable’]) is true?
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.