Changeset 2774354
- Timestamp:
- 08/23/2022 05:31:29 PM (4 years ago)
- Location:
- apppago/trunk
- Files:
-
- 2 added
- 5 edited
-
apppago.php (modified) (2 diffs)
-
assets/css/apppago.css (modified) (1 diff)
-
assets/js/apppago.js (modified) (3 diffs)
-
includes/class-wc-gateway-apppago-amount-models.php (added)
-
includes/class-wc-gateway-apppago-amount.php (added)
-
includes/class-wc-gateway-apppago.php (modified) (4 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
apppago/trunk/apppago.php
r2767968 r2774354 5 5 * Plugin URI: 6 6 * Description: Official APPpago plugin. 7 * Version: 1.0. 27 * Version: 1.0.3 8 8 * Author: SmallPay Srl 9 9 * Author URI: https://www.smallpay.it … … 22 22 } 23 23 24 define('APWC_PLUGIN_VERSION', '1.0. 2');24 define('APWC_PLUGIN_VERSION', '1.0.3'); 25 25 26 26 class WC_APPpago -
apppago/trunk/assets/css/apppago.css
r2767968 r2774354 3 3 * Plugin URI: 4 4 * Description: Official APPpago plugin. 5 * Version: 1.0. 25 * Version: 1.0.3 6 6 * Author: SmallPay Srl 7 7 * Author URI: SmallPay Srl -
apppago/trunk/assets/js/apppago.js
r2764961 r2774354 1 class ErrorHandler { 2 3 constructor() 4 { 5 this.wrapper = document.querySelector('.woocommerce-notices-wrapper'); 6 this.messagesList = document.querySelector('ul.woocommerce-error'); 7 } 8 9 appendPreparedErrorMessageElement(errorMessageElement) 10 { 11 if(this.messagesList === null) { 12 this.prepareMessagesList(); 13 } 14 15 this.messagesList.replaceWith(errorMessageElement); 16 } 17 18 message(text, persist = false) 19 { 20 if(! typeof String || text.length === 0){ 21 throw new Error('A new message text must be a non-empty string.'); 22 } 23 24 if(this.messagesList === null){ 25 this.prepareMessagesList(); 26 } 27 28 if (persist) { 29 this.wrapper.classList.add('ppcp-persist'); 30 } else { 31 this.wrapper.classList.remove('ppcp-persist'); 32 } 33 34 let messageNode = this.prepareMessagesListItem(text); 35 this.messagesList.appendChild(messageNode); 36 37 jQuery.scroll_to_notices(jQuery('.woocommerce-notices-wrapper')) 38 } 39 40 prepareMessagesList() 41 { 42 if(this.messagesList === null){ 43 this.messagesList = document.createElement('ul'); 44 this.messagesList.setAttribute('class', 'woocommerce-error'); 45 this.messagesList.setAttribute('role', 'alert'); 46 this.wrapper.appendChild(this.messagesList); 47 } 48 } 49 50 prepareMessagesListItem(message) 51 { 52 const li = document.createElement('li'); 53 li.innerHTML = message; 54 55 return li; 56 } 57 58 clear() 59 { 60 if (this.messagesList === null) { 61 return; 62 } 63 64 this.messagesList.innerHTML = ''; 65 } 66 } 67 68 1 69 jQuery(document).ready(function($) { 2 70 function paymentCompleted(response) { … … 7 75 8 76 async function buttonClicked() { 77 if (checkRequiredInput()) { 78 throw new Error(); 79 } 80 81 9 82 let possRates = $('#apppago_button_possiblerates').val().split(',').map(str => { 10 83 return Number(str); … … 35 108 }); 36 109 110 function checkRequiredInput() { 111 const errorHandler = new ErrorHandler(); 112 errorHandler.clear(); 113 114 const requiredFields = jQuery('form.woocommerce-checkout .validate-required:visible :input'); 115 requiredFields.each((i, input) => { 116 jQuery(input).trigger('validate'); 117 }); 118 const invalidFields = Array.from(jQuery('form.woocommerce-checkout .validate-required.woocommerce-invalid:visible')); 119 if (invalidFields.length) { 120 const messages = invalidFields.map(el => { 121 const name = el.querySelector('[name]')?.getAttribute('name'); 122 123 let label = el.querySelector('label').textContent 124 .replaceAll('*', '') 125 .trim(); 126 return "%s è un campo richiesto." 127 .replace('%s', `<strong>${label}</strong>`) 128 }).filter(s => s.length > 2); 129 130 if (messages.length) {1 131 messages.forEach((s, i) => errorHandler.message(s)); 132 } 133 134 return messages.length > 0; 135 } 136 } 137 37 138 function checkPaymentMethod() { 139 const setVisible = (selectorOrElement, show, important = false) => { 140 const element = document.querySelector(selectorOrElement); 141 if (!element) { 142 return; 143 } 144 const currentValue = element.style.getPropertyValue('display'); 145 if (!show) { 146 if (currentValue === 'none') { 147 return; 148 } 149 150 console.log(element, "Display none"); 151 element.style.setProperty('display', 'none', important ? 'important' : ''); 152 153 } else { 154 if (currentValue === 'none') { 155 element.style.removeProperty('display'); 156 } // still not visible (if something else added display: none in CSS) 157 const isVisible = !!(element.offsetWidth || element.offsetHeight || element.getClientRects().length); 158 if (!isVisible) { 159 element.style.setProperty('display', 'block'); 160 } 161 console.log("Remove Display none"); 162 } 163 }; 164 38 165 jQuery(document).ready(function($) { 39 166 if($('#payment_method_apppago').is(':checked')){ 40 $('#place_order').hide()167 setVisible('#place_order', false); 41 168 } 42 $('#payment').on('change',function (){ 43 if($('#payment_method_apppago').is(':checked')) { 44 $('#place_order').hide() 45 } else { 46 $('#place_order').show() 47 } 169 $('#payment').on('change', function (){ 170 setVisible('#place_order', !$('#payment_method_apppago').is(':checked')); 48 171 clearInterval(intervalId); 49 172 }) -
apppago/trunk/includes/class-wc-gateway-apppago.php
r2767968 r2774354 7 7 protected $module_version; 8 8 protected $oConfig; 9 protected $amount_handler; 9 10 public static $lastId = 0; 10 11 public static $lastColumn = null; … … 16 17 { 17 18 require_once "class-wc-gateway-apppago-api.php"; 19 require_once "class-wc-gateway-apppago-amount.php"; 20 require_once "class-wc-gateway-apppago-amount-models.php"; 18 21 require_once "constant_apppago.php"; 22 19 23 $this->id = static::GATEWAY_ID; 20 24 $this->method_title = __('APPpago', 'apppago'); 21 25 $this->method_description = __('Allow the customer to pay by installments.', 'apppago'); 22 26 23 $this->module_version = '1.0. 2';27 $this->module_version = '1.0.3'; 24 28 25 29 $this->has_fields = true; … … 36 40 $this->oConfig = new WC_Gateway_APPpago_Configuration($this->settings); 37 41 $this->form_fields = $this->oConfig->get_form_fields(); 42 43 $this->amount_handler = new AmountFactory(); 38 44 39 45 $this->title = __('APPpago', 'apppago'); … … 548 554 $installmentsInfo = $this->oConfig->get_installments_number(WC()->cart); 549 555 550 $amount = preg_replace('#[^\d' . wc_get_price_decimal_separator() . ']#', '', strip_tags(WC()->cart->get_total())); 551 $amount = absint(round(wc_format_decimal(((float) $amount * 100), wc_get_price_decimals()))); 556 $amount = $this->amount_handler->from_wc_cart(WC()->cart)->value_str(); 552 557 553 558 $serviceID = $this->oConfig->ap_service; -
apppago/trunk/readme.txt
r2767968 r2774354 8 8 WC Requires at least: 3.0.0 9 9 WC Tested up to: 6.5.1 10 Stable tag: 1.0. 210 Stable tag: 1.0.3 11 11 License: GNU General Public License v3.0 12 12 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 65 65 66 66 = 1.0.1 = 67 * Updated environment variables for development eand other generic fix67 * Updated environment variables for development and other generic fix 68 68 69 69 = 1.0.2 = 70 70 * Amount calculation update 71 72 = 1.0.3 = 73 * Updated check on mandatory fields in checkout page
Note: See TracChangeset
for help on using the changeset viewer.