Skip to content

Commit

Permalink
Merge pull request #122 from wpsmartpay/dev
Browse files Browse the repository at this point in the history
Fix: Coupon is not reducing the price for both Product and Form
  • Loading branch information
atiq-ur authored Jan 8, 2023
2 parents 9acc885 + 2e0898d commit 4bb5b65
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 29 deletions.
2 changes: 1 addition & 1 deletion app/Modules/Coupon/Coupon.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function showAppliedCouponData($form)

<div class="py-2">
<p class="d-flex justify-content-between m-0">
<span class="font-weight-bold"><?php _e('Total due', 'smartpay'); ?></span>
<span class="font-weight-bold"><?php _e('Total Amount', 'smartpay'); ?></span>
<span class="total-amount-value"></span>
</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wp-smartpay",
"version": "2.7.3",
"version": "2.7.4",
"description": "A simple plugin for receiving payment.",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion public/js/app.js

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Contributors: themesgrove
Tags: download manager, digital product, donation, ecommerce, stripe, paypal, paddle, document manager, file manager, download protection, recurring payment, donations, donation plugin, wordpress donation plugin, wp donation, fundraising, fundraiser, crowdfunding, wordpress donations, gutenberg, gutenberg donations, nonprofit, paypal donations, paypal donate, stripe donations, stripe donate, authorize.net, authorize.net donations, bkash, bkash payment,
Requires at least: 4.9
Tested up to: 6.1
Tested up to: 6.1.1
Requires PHP: 7.4.0
Stable Tag: 2.7.3
Stable Tag: 2.7.4
License: GNU Version 2 or later

The Simplest way to sell digital downloads and set up payment forms with Stripe, Paypal and Paddle. Accept donations, service payment and manage downloads with ease.
Expand Down Expand Up @@ -122,6 +122,10 @@ The easiest way to install WP SmartPay is to search for it via your site’s Das
7. Seamless one click checkout

== Changelog ==
= [2.7.4] =
* Fix - Coupon is not reduced price for both From and Product.
* Update - Node Package dependencies.

= [2.7.3] =
* Fix - Form builder is not working with the WP version 6.1.

Expand Down
41 changes: 21 additions & 20 deletions resources/js/frontend/payment/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,16 @@ jQuery(($) => {
`<div class="alert alert-success">${response.data.message}</div>`
)

let discountAmount = response.data.discountAmount
$couponData = response.data.couponData
$currency = response.data.currency

$('#smartpay-payment-form').addClass('coupon-applied')
let payment_form = $('#smartpay-payment-form');
let discountAmountContainer = $('.discount-amounts-container');

$('#smartpay-payment-form')
payment_form.addClass('coupon-applied')

payment_form
.find('.form--fixed-amount')
.each(function () {
let $inputId = $(this)
Expand All @@ -220,37 +224,32 @@ jQuery(($) => {
.val($couponData[$inputId].discountAmount)
})

let $selectedAmountInputId = $(
'#smartpay-payment-form .form-amounts'
)
.find(
'.form--fixed-amount.selected input[name=_form_amount]'
)
let $selectedAmountInputId = $('#smartpay-payment-form .form-amounts')
.find('.plan-amount.selected input[name=_form_amount]')
.attr('id')

$(
'#smartpay-payment-form input[name=smartpay_form_amount]'
).val($couponData[$selectedAmountInputId].discountAmount)
$('#smartpay-payment-form input[name=smartpay_form_amount]')
.val($couponData[$selectedAmountInputId].discountAmount)

$('.discount-amounts-container').removeClass('d-none')
discountAmountContainer.removeClass('d-none')

$('.discount-amounts-container')
discountAmountContainer
.find('.subtotal-amount-value')
.html(
`${$currency}${$couponData[$selectedAmountInputId].mainAmount}`
)

$('.discount-amounts-container')
discountAmountContainer
.find('.coupon-amount-name')
.html(response.data.couponCode)
.html(`Discount - ${response.data.couponCode}`)

$('.discount-amounts-container')
discountAmountContainer
.find('.coupon-amount-value')
.html(
`-${$currency}${$couponData[$selectedAmountInputId].couponAmount}`
)

$('.discount-amounts-container')
discountAmountContainer
.find('.total-amount-value')
.html(
`${$currency}${$couponData[$selectedAmountInputId].discountAmount}`
Expand All @@ -274,19 +273,21 @@ jQuery(($) => {
.find('input[name=_form_amount]')
.attr('id')

$('.discount-amounts-container')
let discountAmountContainer = $('.discount-amounts-container');

discountAmountContainer
.find('.subtotal-amount-value')
.html(
`${$currency}${$couponData[$selectAmountInputId].mainAmount}`
)

$('.discount-amounts-container')
discountAmountContainer
.find('.coupon-amount-value')
.html(
`-${$currency}${$couponData[$selectAmountInputId].couponAmount}`
)

$('.discount-amounts-container')
discountAmountContainer
.find('.total-amount-value')
.html(
`${$currency}${$couponData[$selectAmountInputId].discountAmount}`
Expand Down
4 changes: 2 additions & 2 deletions resources/js/frontend/payment/product.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ jQuery(($) => {

discountAmountContainer
.find('.coupon-amount-name')
.html(response.data.couponCode)
.html(`Discount - ${response.data.couponCode}`)

discountAmountContainer
.find('.coupon-amount-value')
Expand All @@ -539,7 +539,7 @@ jQuery(($) => {
.find('.total-amount-value')
.html(`${$currency}${$couponData.discountAmount}`)

discountAmountContainer
$('.smartpay-product-shortcode')
.find('input[name=smartpay_product_price]')
.val(`${$couponData.discountAmount}`)

Expand Down
4 changes: 2 additions & 2 deletions smartpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: Simplest way to sell digital downloads and fundraise with WordPress. Easily connect Paddle, Stripe, Paypal to accept donations and manage downloads.
* Plugin URI: https://wpsmartpay.com/?utm_source=wp-plugins&utm_campaign=plugin-uri&utm_medium=wp-dash
* Tags: download manager, digital product, donation, ecommerce, paddle, stripe, paypal, document manager, file manager, download protection, recurring payment, donations, donation plugin, wordpress donation plugin, wp donation, fundraising, fundraiser, crowdfunding, wordpress donations, gutenberg, gutenberg donations, nonprofit, paypal donations, paypal donate, stripe donations, stripe donate, authorize.net, authorize.net donations, bkash, bkash payment,
* Version: 2.7.3
* Version: 2.7.4
* Author: WPSmartPay
* Author URI: https://wpsmartpay.com/?utm_source=wp-plugins&utm_campaign=author-uri&utm_medium=wp-dash
* Text Domain: smartpay
Expand All @@ -27,7 +27,7 @@

defined('ABSPATH') || exit;

define('SMARTPAY_VERSION', '2.7.3');
define('SMARTPAY_VERSION', '2.7.4');
define('SMARTPAY_PLUGIN_FILE', __FILE__);
define('SMARTPAY_PLUGIN_ASSETS', plugins_url('public', __FILE__));
define('SMARTPAY_STORE_URL', 'https://wpsmartpay.com/');
Expand Down

0 comments on commit 4bb5b65

Please sign in to comment.