From dac3c9f6f7c7081251d7bfaa105c412000206398 Mon Sep 17 00:00:00 2001 From: Kocmonavtik <61938582+Kocmonavtik@users.noreply.github.com> Date: Thu, 12 Sep 2024 09:40:05 +0300 Subject: [PATCH] Adding loyalty program coupon entry to form by click (#343) --- CHANGELOG.md | 3 +++ VERSION | 2 +- src/assets/js/retailcrm-loyalty-cart.js | 6 ++++++ src/include/class-wc-retailcrm-base.php | 7 +++++++ src/include/class-wc-retailcrm-loyalty.php | 2 +- src/readme.txt | 5 ++++- src/retailcrm.php | 2 +- src/uninstall.php | 2 +- 8 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 src/assets/js/retailcrm-loyalty-cart.js diff --git a/CHANGELOG.md b/CHANGELOG.md index ace8500..ce47b43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2024-09-11 4.8.3 +* Added loyalty program coupon entry in the form by click + ## 2024-08-26 4.8.2 * Fixed base file customization issue * Added a hook to update the list of meta fields diff --git a/VERSION b/VERSION index 326ec63..f99c658 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.8.2 +4.8.3 diff --git a/src/assets/js/retailcrm-loyalty-cart.js b/src/assets/js/retailcrm-loyalty-cart.js new file mode 100644 index 0000000..6a98185 --- /dev/null +++ b/src/assets/js/retailcrm-loyalty-cart.js @@ -0,0 +1,6 @@ +function inputLoyaltyCode() { + let couponInput = document.getElementById('coupon_code'); + let couponCode = document.getElementById('input_loyalty_code'); + + couponInput.value = couponCode.innerText; +} diff --git a/src/include/class-wc-retailcrm-base.php b/src/include/class-wc-retailcrm-base.php index 1792d0c..c2404d5 100644 --- a/src/include/class-wc-retailcrm-base.php +++ b/src/include/class-wc-retailcrm-base.php @@ -747,6 +747,13 @@ if (!class_exists('WC_Retailcrm_Base')) { if ($result) { echo $result; } + + $jsScriptPath = plugins_url() . self::ASSETS_DIR . '/js/retailcrm-loyalty-cart.js'; + $wpAdminUrl = ['url' => get_admin_url()]; + + wp_register_script('retailcrm-loyalty-cart', $jsScriptPath, false, '0.1'); + wp_enqueue_script('retailcrm-loyalty-cart', $jsScriptPath, '', '', true); + wp_localize_script('retailcrm-loyalty-cart', 'AdminUrl', $wpAdminUrl); } catch (Throwable $exception) { writeBaseLogs($exception->getMessage()); } diff --git a/src/include/class-wc-retailcrm-loyalty.php b/src/include/class-wc-retailcrm-loyalty.php index 0ec3010..8b9902c 100644 --- a/src/include/class-wc-retailcrm-loyalty.php +++ b/src/include/class-wc-retailcrm-loyalty.php @@ -254,7 +254,7 @@ if (!class_exists('WC_Retailcrm_Loyalty')) : } $resultString .= '
' . __('It is possible to write off', 'retailcrm') . ' ' . $lpDiscountSum . ' ' . __('bonuses', 'retailcrm') . '
'; - return $resultString. '
' . __('Use coupon:', 'retailcrm') . ' ' . $coupon->get_code() . '
'; + return $resultString. '
' . __('Use coupon:', 'retailcrm') . ' ' . $coupon->get_code() . '
'; } public function clearLoyaltyCoupon() diff --git a/src/readme.txt b/src/readme.txt index b827746..45e1b7c 100644 --- a/src/readme.txt +++ b/src/readme.txt @@ -5,7 +5,7 @@ Tags: Интеграция, Simla.com, simla Requires PHP: 7.0 Requires at least: 5.3 Tested up to: 6.5 -Stable tag: 4.8.2 +Stable tag: 4.8.3 License: GPLv1 or later License URI: http://www.gnu.org/licenses/gpl-1.0.html @@ -82,6 +82,9 @@ Asegúrate de tener una clave API específica para cada tienda. Las siguientes i == Changelog == += 4.8.3 = +* Added loyalty program coupon entry in the form by click + = 4.8.2 = * Fixed base file customization issue * Added a hook to update the list of meta fields diff --git a/src/retailcrm.php b/src/retailcrm.php index 6d277d0..0848cdf 100644 --- a/src/retailcrm.php +++ b/src/retailcrm.php @@ -5,7 +5,7 @@ * Description: Integration plugin for WooCommerce & Simla.com * Author: RetailDriver LLC * Author URI: http://retailcrm.pro/ - * Version: 4.8.2 + * Version: 4.8.3 * Tested up to: 6.5 * Requires Plugins: woocommerce * WC requires at least: 5.4 diff --git a/src/uninstall.php b/src/uninstall.php index 839c519..15381d1 100644 --- a/src/uninstall.php +++ b/src/uninstall.php @@ -16,7 +16,7 @@ * * @link https://wordpress.org/plugins/woo-retailcrm/ * - * @version 4.8.2 + * @version 4.8.3 * * @package RetailCRM */