メインコンテンツにスキップ
バージョン: 2.x

Smart Coupons

The WCPOS StoreApps Smart Coupons extension lets a store-credit coupon from Smart Coupons by StoreApps, such as a gift card, pay toward a POS sale. With WCPOS Pro, you take the card on the checkout's payment page, the right amount comes off it, and the receipt shows the balance left.

Add Discount can't take store credit

A gift card in the cart's Add Discount gets Coupon not found. Take it on the checkout's Legacy tab instead: see Take a gift card at the till.

Take a gift card at the till​

Before you start, the administrator has installed this extension with Smart Coupons by StoreApps active. You also need a payment method on the checkout's Legacy tab: that tab opens the store's own payment page, which has a coupon box.

  1. Build the cart, press Checkout and open the Legacy tab. The store's payment page opens in the checkout.
  2. Type the gift card's code in Coupon code and press Apply coupon. The order total drops by the amount the card covers.
  3. Choose the payment method the customer pays the rest with, take the payment on that page, then press Process Payment.
  4. On the receipt, check the coupon's discount row for Store credit balance, as in What the receipt shows. If it's missing, see If something goes wrong.

If the Legacy tab has no payment methods, there is no payment page to take the card on. Take the payment as usual and ask the customer to keep their gift card for a later purchase: nothing has come off it.

What the receipt shows​

The coupon's discount row ends with the card's balance when the receipt is made. On the Standard Receipt, a store-credit coupon whose description is Gift card prints:

Discount · Gift card — Store credit balance: $61.50

On the receipt at checkout, that is the balance right after the sale. Your receipt template needs nothing new. If the coupon has no description, the row still ends with Store credit balance. To print Gift Card instead of Discount on that row, see For developers.

What it does​

StoreApps keeps gift-card balances for online orders, but on its own it misses orders paid at the POS. When a POS order carries a store-credit coupon, the extension:

  • Takes off what was spent, and no more. It records how much of the card the order used, so StoreApps deducts that amount and leaves the rest on the card.
  • Lowers the balance when the order is paid. Never when the coupon goes on, and never twice.
  • Forgets a coupon you took off. If the coupon is removed before payment, nothing is deducted for it.
  • Notes it on the order. See The note on the order.
  • Prints the balance on the receipt. See What the receipt shows.

With StoreApps Smart Coupons switched off, the extension does nothing.

Install the extension​

An administrator installs it once in WP Admin: from POS → Settings → Extensions with WCPOS Pro, or by uploading its release with the free plugin.

Install steps, with WCPOS Pro or the free plugin
Before you start

You need an administrator login to WP Admin, and Smart Coupons by StoreApps (sold on WooCommerce.com) active on the site. The extension works only with that plugin, not with other plugins that have "Smart Coupons" in their name.

With WCPOS Pro​

  1. In WP Admin, go to POS → Settings → Extensions.
  2. Find WCPOS StoreApps Smart Coupons and press Install.
  3. Press Activate.

See Install an extension for updates and auto-updates.

With the free plugin​

The Extensions screen lists the extension, but its buttons need Pro. Instead:

  1. Download wcpos-storeapps-smart-coupons.zip from the extension's latest release.
  2. In WP Admin, go to Plugins → Add Plugin and press Upload Plugin.
  3. Choose the file you downloaded and press Install Now.
  4. Press Activate Plugin.

There is nothing to set up after that. Create store-credit coupons or gift cards in WooCommerce as usual.

The note on the order​

When the order is paid, the extension adds one private note to it. Staff see it on the order in WP Admin → WooCommerce → Orders:

StoreApps Smart Coupons store credit recorded for WCPOS: Coupon store100 used $38.50. Current balance: $61.50.

Use it to check which card paid, how much it covered, and what was left on it. The note is added once per order.

Refunds and cancellations​

The extension doesn't put credit back. When you refund or cancel an order paid partly with store credit, StoreApps decides what happens to the balance. Check the coupon's amount in WP Admin → Marketing → Coupons afterwards. If it's not what the customer should have, ask your store administrator: they can change the coupon's amount there.

If something goes wrong​

Coupon not found when you apply a gift card from Add Discount. In WCPOS 2.0, Add Discount only applies percentage, fixed cart and fixed product coupons, so a store-credit coupon gets Coupon not found there, with or without this extension. Use the payment page on the Legacy tab instead.

The balance didn't go down after the sale. Check that both Smart Coupons and WCPOS StoreApps Smart Coupons are active in Plugins. The deduction happens when the order is paid, not when the coupon goes on. An order with no store-credit note was not deducted by the extension.

The receipt has no balance. A receipt printed while the till is offline has no balance. Print it again once the till is back online. If it's still missing, your receipt template doesn't print the discount row's label; see Receipt Data.

For developers: stored data and hooks

The extension adds no WCPOS coupon fields. It works through WooCommerce order meta and StoreApps' own balance logic. It applies only to POS orders (wcpos_is_pos_order(): created_via is woocommerce-pos) and only to coupons of type smart_coupon.

  • Usage. On woocommerce_order_after_calculate_totals it writes StoreApps' smart_coupons_contribution order meta (coupon code → amount used) and wc_sc_environment, when StoreApps hasn't. It drops entries for coupons no longer on the unpaid order.
  • Payment-page coupon box. That form is a plain front-end POST to WC_Order::apply_coupon(), which StoreApps doesn't treat as an order context. While an unpaid POS order with a smart_coupon line recalculates outside a REST request, the extension reports a REST context so StoreApps' own order-discount logic runs.
  • Deduction. A POS order is paid from pos-open or pos-partial, and StoreApps only deducts on a move from pending or failed. On woocommerce_order_status_changed from any other status to a paid status or on-hold, it calls StoreApps' WC_SC_Coupon_Process::update_smart_coupon_balance(), which marks each coupon line so it never deducts twice.
  • Order note. Added on the move to processing, completed or on-hold, once per order (_wcpos_storeapps_smart_coupons_audit_note_added).
  • Receipt. It filters woocommerce_coupon_get_description while a WCPOS receipt renders, and on the receipt data filter it adds gift_card: true to the store-credit row in discounts and appends the balance to its label. A template can then print:
{{#discounts}}{{#gift_card}}Gift Card{{/gift_card}}{{^gift_card}}{{i18n.discount}}{{/gift_card}} · {{label}}{{/discounts}}
  • Hook names. Version 0.2.3 still hooks the pre-2.0 names woocommerce_pos_receipt_data, woocommerce_pos_before_template_render and woocommerce_pos_after_template_render. WCPOS 2.0 still fires them after their wcpos_ names, and WordPress logs a deprecation notice for each when WP_DEBUG is on. See Hook naming.

Source: github.com/wcpos/wcpos-storeapps-smart-coupons.

With WCPOS Pro

The till takes a gift card on the Legacy tab's payment page, and you install and update the extension from POS → Settings → Extensions. Without Pro, install it by hand from its release, as above.