Support » Plugin: WooCommerce » Apply coupon in /checkout/order-pay
Apply coupon in /checkout/order-pay
-
I’m trying to set up coupons for customers when viewing their orders that aren’t completed yet. However the coupons are added to the cart and not to the actual order. If I apply a coupon from backend then it works as it should but not from customers frontend.
I’ve modified my
/templates/checkout/form-pay.php
to include the add coupon form:`
<?php wc_get_template( ‘checkout/form-coupon.php’ ); ?>
`
The form gets included and the ajax works but the coupong gets applied to the cart and not the order.
Any idea of what the problem might be here?
-
Are you trying to customize the default process or is there an actual problem here?
I think it’s a problem because when I apply the coupon from backend on my order it works. When the coupon is applied through frontend on my order (not cart) it doesn’t get applied.
Can I see a URL and a give me a coupon code to apply please. Also, grab a copy of your system report woocommerce > status > get system report. Paste that back here like you would code.
Here is the system report
### WordPress Environment ### WordPress address (URL): https://XXXX Site address (URL): https://XXXX WC Version: 3.6.3 Log Directory Writable: ✔ WP Version: 5.2 WP Multisite: – WP Memory Limit: 256 MB WP Debug Mode: – WP Cron: ✔ Language: en_US External object cache: – ### Server Environment ### Server Info: Apache/2.4.10 (Debian) PHP Version: 7.0.32-1~dotdeb+8.1 - We recommend using PHP version 7.2 or above for greater performance and security. How to update your PHP version PHP Post Max Size: 10 MB PHP Time Limit: 60 PHP Max Input Vars: 2500 cURL Version: 7.38.0 OpenSSL/1.0.1t SUHOSIN Installed: – MySQL Version: ❌ 5.5.62-0+deb8u1 - We recommend a minimum MySQL version of 5.6. See: WordPress requirements Max Upload Size: 10 MB Default Timezone is UTC: ✔ fsockopen/cURL: ✔ SoapClient: ✔ DOMDocument: ✔ GZip: ✔ Multibyte String: ✔ Remote Post: ✔ Remote Get: ✔ ### Database ### WC Database Version: 3.6.3 WC Database Prefix: wp_ MaxMind GeoIP Database: ✔ Total Database Size: 8.67MB Database Data Size: 5.59MB Database Index Size: 3.08MB wp_woocommerce_sessions: Data: 0.02MB + Index: 0.02MB wp_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB wp_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB wp_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB wp_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB wp_woocommerce_order_itemmeta: Data: 0.05MB + Index: 0.03MB wp_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB wp_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB wp_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB wp_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB wp_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB wp_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB wp_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB wp_woocommerce_log: Data: 0.02MB + Index: 0.02MB wp_commentmeta: Data: 0.02MB + Index: 0.03MB wp_comments: Data: 0.02MB + Index: 0.09MB wp_failed_jobs: Data: 0.02MB + Index: 0.00MB wp_links: Data: 0.02MB + Index: 0.02MB wp_mailchimp_carts: Data: 0.02MB + Index: 0.00MB wp_media_folders_lists: Data: 0.02MB + Index: 0.00MB wp_media_folder_file_relationship: Data: 0.02MB + Index: 0.00MB wp_mgmlp_folders: Data: 0.00MB + Index: 0.00MB wp_mondido_customers: Data: 0.02MB + Index: 0.02MB wp_options: Data: 2.08MB + Index: 0.08MB wp_pantheon_sessions: Data: 2.52MB + Index: 1.86MB wp_postmeta: Data: 0.17MB + Index: 0.17MB wp_posts: Data: 0.08MB + Index: 0.06MB wp_queue: Data: 0.02MB + Index: 0.00MB wp_termmeta: Data: 0.02MB + Index: 0.03MB wp_terms: Data: 0.02MB + Index: 0.03MB wp_term_relationships: Data: 0.02MB + Index: 0.02MB wp_term_taxonomy: Data: 0.02MB + Index: 0.03MB wp_usermeta: Data: 0.02MB + Index: 0.03MB wp_users: Data: 0.02MB + Index: 0.05MB wp_wc_download_log: Data: 0.02MB + Index: 0.03MB wp_wc_product_meta_lookup: Data: 0.02MB + Index: 0.09MB wp_wc_webhooks: Data: 0.02MB + Index: 0.02MB wp_wsluserscontacts: Data: 0.02MB + Index: 0.02MB wp_wslusersprofiles: Data: 0.02MB + Index: 0.03MB wp_wslwatchdog: Data: 0.03MB + Index: 0.00MB ### Post Type Counts ### attachment: 13 customize_changeset: 9 mgmlp_media_folder: 9 nav_menu_item: 2 page: 5 product: 8 revision: 11 scheduled-action: 15 shop_coupon: 3 shop_order: 29 ### Security ### Secure connection (HTTPS): ✔ Hide errors from visitors: ✔ ### Active Plugins (12) ### Native PHP Sessions for WordPress: by Pantheon – 0.7.0 JSON Basic Authentication: by WordPress API Team – 0.1 WooCommerce Mondido Payments Gateway: by Mondido – 4.3.1 – Not tested with the active version of WooCommerce Breeze: by Cloudways – 1.0.10 Jetpack by WordPress.com: by Automattic – 7.3.1 Mailchimp for WooCommerce: by Mailchimp – 2.1.16 – Not tested with the active version of WooCommerce Organize Media Library by Folders: by Katsushi Kawamori – 6.44 WooCommerce Blocks: by Automattic – 2.1.0 WooCommerce Google Analytics Integration: by WooCommerce – 1.4.9 WooCommerce Services: by Automattic – 1.20.0 WooCommerce: by Automattic – 3.6.3 WordPress Social Login for Struktanalys: by Miled Vatan – 5.1.0-Struktanalys ### Inactive Plugins (4) ### Akismet Anti-Spam: by Automattic – 4.1.2 Hello Dolly: by Matt Mullenweg – 1.7.1 Klarna Checkout for WooCommerce: by Krokedil – 1.8.4 – Not tested with the active version of WooCommerce Klarna Order Management for WooCommerce: by klarna krokedil – 1.2.5 – Not tested with the active version of WooCommerce ### Settings ### API Enabled: ✔ Force SSL: – Currency: SEK (kr) Currency Position: right Thousand Separator: Decimal Separator: , Number of Decimals: 2 Taxonomies: Product Types: external (external) grouped (grouped) simple (simple) variable (variable) Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog) exclude-from-search (exclude-from-search) featured (featured) outofstock (outofstock) rated-1 (rated-1) rated-2 (rated-2) rated-3 (rated-3) rated-4 (rated-4) rated-5 (rated-5) Connected to WooCommerce.com: – ### WC Pages ### Shop base: #7 - / Cart: #8 - /cart Checkout: #9 - /checkout My account: #10 - /my-account Terms and conditions: #3 - /privacy-policy ### Theme ### Name: Storefront Child Theme Version: 1.0.1 Author URL: http://memoria.se Child Theme: ✔ Parent Theme Name: Storefront Parent Theme Version: 2.4.5 – 2.5.0 is available Parent Theme Author URL: https://woocommerce.com/ WooCommerce Support: ✔ ### Templates ### Overrides: storefront-child/woocommerce/auth/form-login.php storefront-child/woocommerce/checkout/form-login.php storefront-child/woocommerce/checkout/form-pay.php storefront-child/woocommerce/global/form-login.php version 3.3.0 is out of date. The core version is 3.6.0 storefront-child/woocommerce/myaccount/form-login.php version 3.5.0 is out of date. The core version is 3.6.0 Outdated Templates: ❌ Learn how to update ### Action Scheduler ### Complete: 15 Oldest: 2019-05-19 16:00:40 +0200 Newest: 2019-05-19 16:01:54 +0200 Pending: 0 Oldest: – Newest: – Canceled: 0 Oldest: – Newest: – In-progress: 0 Oldest: – Newest: – Failed: 0 Oldest: – Newest: –
@vato – Do you have a coupon we can test with on a staging site? At the moment we don’t have quite enough information to troubleshoot what’s going 🙂
@vato update your template files and the parent theme. You have a few outdated files so you’re open to conflicts.
Hi @riaanknoetze and @serafinnyc
I’ve created a temporary account
name: testwoo
pass: mywoopasswordGo to /wp-admin to sign in and then you will see all your orders. There are two orders
1. Free product
2. Not free productUse the coupon coupon1 to get 50% discount
Thank you for your help!
@vato sorry @riaanknoetze meant do you have a coupon code we can test with. You’re not really allowed to put login creds on this forum.
You should delete that information immediately.
I had no problem adding coupon1 on the cart page.
@serafinnyc Yes it’s possible from cart page but not from orders page. If you login with the test account I provided you then you can see that you aren’t able apply the coupon successfully on the order. It says it’s applied but the total value hasn’t changed. If I apply the coupon from backend then total value is changed.
https://<domain>/my-account/orders-
This reply was modified 4 years ago by
vato.
wrong post…
Your request seems to have changed. I don’t recall any mention of My Account Orders page at all. If this is the case you cannot add a coupon there without writing Ajax to match.
This is customized work, not an issue.
Sorry I mixed up the responses from another post I have which is related to this.
As I mentiond in my intial post, I’ve modified the
form-pay.php
to include the templateform-coupon.php
. This applies a coupon but not on the order itself but on the cart. If I apply the coupon from backend then it becomes correct.I’m going to wait for @riaanknoetze to join or some other advisor because I understood your initial request to be solely related to the cart page and that was it. Cart page does not equal My Account page and now we’re all over the map.
Yep, I’m with @serafinnyc on this one – I’m having a hard time following what’s currently happening, what should be happening and what you’re expecting to happen.
For what it’s worth, using “coupon1” on your checkout page does work as expected. Here’s what I’m seeing:
Link to image: https://cld.wthms.co/tJOolI -
This reply was modified 4 years ago by
- The topic ‘Apply coupon in /checkout/order-pay’ is closed to new replies.