Free Gift Coupons v3.8.0 – WooPayments Pay-for-Order Fix, Cart Block Updates & New Minimum Requirements

Free Gift Coupons 3.8.0 fixes a fatal error on the pay-for-order page of stores using WooPayments and moves the free gift checks for the Cart and Checkout blocks onto WooCommerce’s Store API. Gift lines in the Cart and Mini Cart blocks hide their quantity stepper, and the cart’s edit button picks up your theme’s button styling. The release also raises the minimum requirements to PHP 7.4, WordPress 6.2 and WooCommerce 8.2, and is tested with WooCommerce 10.2.0. There is no database update with this release.

Important: Free Gift Coupons 3.8.0 requires PHP 7.4, WordPress 6.2 and WooCommerce 8.2 or newer. Earlier releases accepted PHP 7.2, WordPress 4.4 and WooCommerce 3.6. Check your hosting control panel and your WordPress and WooCommerce versions before updating.

Updates

New minimum requirements: PHP 7.4, WordPress 6.2 and WooCommerce 8.2

Free Gift Coupons 3.8.0 requires PHP 7.4 or newer, WordPress 6.2 or newer and WooCommerce 8.2 or newer. Previous releases listed PHP 7.2, WordPress 4.4 and WooCommerce 3.6 as their minimums. With WooCommerce 8.2 as the floor, support for the Cart and Checkout blocks and the Store API loads on every store; it used to load only when a new enough WooCommerce Blocks package was detected.

Tested with WooCommerce 10.2

Free Gift Coupons 3.8.0 is tested with WooCommerce 10.2.0 and WordPress 6.6.0.

Fixes

No fatal error on the WooPayments pay-for-order page

Free Gift Coupons filters every response from WooCommerce’s Store API so that free gift lines show a zero price and a locked quantity. That filter read the shopper’s cart on every Store API route. The Store API’s order route, which WooPayments uses for its pay-for-order page, has no cart attached. The request ended in a PHP fatal error (“Call to a member function get_cart() on null”), and the customer could not pay for the order. 3.8.0 checks for a cart first and leaves the response untouched when there is none. Cart and checkout responses are filtered as before.

Improvements

Gift checks in the Cart and Checkout blocks run once, through the Store API

When a coupon is removed or stops being valid, Free Gift Coupons removes its gift from the cart and shows the notice “A gift item which is no longer available was removed from your cart.” In the classic cart that check runs on WooCommerce’s cart-items hook. The Cart and Checkout blocks have their own validation hook in the Store API, and Free Gift Coupons has a check on it too. 3.8.0 skips the classic check during Store API requests, so in the blocks the gift is validated once, through the Store API path, and the classic cart keeps its existing check.

Free gift lines in the Cart and Mini Cart blocks hide the quantity stepper

Customers cannot change the quantity of a free gift, so the plugin already locked the quantity on gift lines in the Cart block. 3.8.0 also hides the quantity stepper on those lines with a stylesheet rule. The rule applies to the Mini Cart block as well as the Cart block, so a gift line looks the same wherever the block cart appears.

The cart edit button picks up your theme’s button class

For a variable product given as a gift, the cart shows a Choose options button (or Edit options once a variation is chosen) that lets the customer pick their attributes. In both the classic cart and the Cart block that button now takes the class name WordPress provides for the theme’s button element. On a block theme it inherits the button colours, padding and radius set in the theme’s styles.

Note for developers: The blocks integration is registered under the name wc-fgc/checkout (previously free_gift_coupons/checkout), its script handle is wc-fgc-checkout-block (previously wc-fgc-checkout-blocks), and the class is WC_FGC_Checkout_Block_Integration (previously WC_FGC_Checkout_Blocks_Integration). The class no longer keeps a static instance: WC_FGC_Checkout_Block_Integration::instance() triggers a doing-it-wrong notice and returns false, and WooCommerce’s integration registry receives a fresh object for the Cart, Mini Cart and Checkout blocks. The blocks loader class is renamed from WC_FGC_Blocks_Compatibility to WC_FGC_Blocks, with the old name kept as an alias. The edit button in the classic cart now carries the theme’s button element class in place of the button class it had before.

Why this matters

  • Customers on stores running WooPayments can pay for an existing order again while Free Gift Coupons is active
  • In the Cart and Checkout blocks a gift is validated once, through the Store API, with the same notice as before
  • Free gift lines look consistent in the Cart block and the Mini Cart block, with no quantity stepper to confuse customers
  • The cart’s edit button follows your block theme’s button styling
  • The plugin now targets current PHP, WordPress and WooCommerce versions, so check your minimums before you update

Similar Posts