Ecommerce Shopify WordPress Discussion

Prevent order go to processing status if condition is true [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about programming within the scope defined in the help center. Closed 14 days ago. Improve this question I 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?
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 30, 2023

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.