1. Documentation /
  2. Smart Coupons /
  3. How to autocomplete gift card order status

How to autocomplete gift card order status

Smart Coupons provide a powerful, “all-in-one” solution for gift cards, store credits, discount coupons, and vouchers extending the core functionality of WooCommerce coupons.

This doc explains how you can mark gift card order status from processing to completed automatically and also what to do if you want to keep the order status as processing.

Smart Coupons autocompletes gift card order

↑ Back to top

Smart Coupons plugin allows you to create and sell store credits / gift cards (as products) in three ways:

  1. Store credit of any amount
  2. Store credits of fixed denominations
  3. Store credits of a fixed amount

Now when customers purchase any of these products, the store credits / gift cards will be auto-generated & sent to the customers via email. As no shipping is required here, by default, the order statuses of these orders are marked as Processing.

However, if you are using Smart Coupons version 6.7.0 or later, the gift card orders will be automatically marked as Completed, by default.

There’s no setting or configuration required.

Note – Here are some cases wherein the orders will be marked as Completed or Processing by Smart Coupons:

  1. If the order contains all virtual products and all are store credit / gift cards, then the order will be marked as Completed.
  2. If the order does not contain a store credit / gift card product, then it will be marked as Processing irrespective of whether that product is virtual or not.
  3. If the order contains any one product that is not virtual, then the order will be marked as Processing.

The above-mentioned cases consider that the payment is completed for the respective orders. If the payment is not completed in the above-mentioned cases then the order status will be handled by WooCommerce & it’ll be set as Pending or Pending payment.

How to disable autocomplete gift card order

↑ Back to top

In case you don’t want the order status to autocomplete and keep the status as Processing, the Smart Coupons plugin provides two ways to disable / stop this feature:

  1. Using custom code snippet (recommended)
  2. Adding / updating a row in the database

Using a custom code snippet (recommended)

↑ Back to top

If you’re familiar with PHP code, you can follow this approach. Add the following custom code snippet to your WordPress and WooCommerce-based website. Refer to the best practices for adding custom code snippets for more details.

/**
 * Make processing necessary for coupon products.
 *
 * @author StoreApps <support@storeapps.org>
 * 
 * @param string $need_processing Whether need processing or not.
 * @param array $args Additional arguments.
 * @return string
 */
function storeapps_wc_sc_coupon_product_need_processing( $need_processing = 'no', $args = array() ) {
    return 'yes';
}
function storeapps_handle_smart_coupons_hooks() {
    add_filter( 'wc_sc_coupon_product_need_processing', 'storeapps_wc_sc_coupon_product_need_processing', 99, 2 );
}
add_action( 'wp_loaded', 'storeapps_handle_smart_coupons_hooks' );

Adding / updating a row in database

↑ Back to top

If you’re more familiar with adding or updating values in the database, follow these steps:

  1. Log in to the database that is linked with your website.
  2. Open table <prefix>options. For examplewp_options.
  3. Search for a row that is having wc_sc_coupon_product_need_processing in the column option_name:
    • If you don’t find any record, then add a new row with wc_sc_coupon_product_need_processing as option_name and yes as option_value. Rest you can keep default and save.
    • If you find a record, then edit the option_value column of that row & set the value as yes and save.
  4. That’s it.

WooCommerce

The most customizable eCommerce platform for building your online business.

  • 30-day money-back guarantee
  • Support teams across the world
  • Safe and secure online payment