Changeset 2919599
- Timestamp:
- 05/31/2023 11:15:13 AM (3 years ago)
- Location:
- buy-one-click-woocommerce
- Files:
-
- 4 added
- 28 edited
- 1 copied
-
tags/2.2.5 (copied) (copied from buy-one-click-woocommerce/trunk)
-
tags/2.2.5/buycli-index.php (modified) (1 diff)
-
tags/2.2.5/js/form.js (modified) (5 diffs)
-
tags/2.2.5/readme.txt (modified) (2 diffs)
-
tags/2.2.5/src/Constant/TranslationString.php (added)
-
tags/2.2.5/src/Controller/FormController.php (modified) (2 diffs)
-
tags/2.2.5/src/Controller/OrderController.php (modified) (2 diffs)
-
tags/2.2.5/src/Core.php (modified) (5 diffs)
-
tags/2.2.5/src/Options/General.php (modified) (1 diff)
-
tags/2.2.5/src/Repository/Order.php (modified) (2 diffs)
-
tags/2.2.5/src/Service/Button.php (modified) (6 diffs)
-
tags/2.2.5/src/Utils/Product.php (modified) (2 diffs)
-
tags/2.2.5/src/Utils/Translation.php (added)
-
tags/2.2.5/templates/forms/customOrderButton.php (modified) (1 diff)
-
tags/2.2.5/templates/forms/file_uploader.php (modified) (1 diff)
-
tags/2.2.5/templates/forms/orderButton.php (modified) (1 diff)
-
tags/2.2.5/templates/forms/order_form.php (modified) (7 diffs)
-
trunk/buycli-index.php (modified) (1 diff)
-
trunk/js/form.js (modified) (5 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/Constant/TranslationString.php (added)
-
trunk/src/Controller/FormController.php (modified) (2 diffs)
-
trunk/src/Controller/OrderController.php (modified) (2 diffs)
-
trunk/src/Core.php (modified) (5 diffs)
-
trunk/src/Options/General.php (modified) (1 diff)
-
trunk/src/Repository/Order.php (modified) (2 diffs)
-
trunk/src/Service/Button.php (modified) (6 diffs)
-
trunk/src/Utils/Product.php (modified) (2 diffs)
-
trunk/src/Utils/Translation.php (added)
-
trunk/templates/forms/customOrderButton.php (modified) (1 diff)
-
trunk/templates/forms/file_uploader.php (modified) (1 diff)
-
trunk/templates/forms/orderButton.php (modified) (1 diff)
-
trunk/templates/forms/order_form.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
buy-one-click-woocommerce/tags/2.2.5/buycli-index.php
r2864638 r2919599 5 5 * Plugin URI: http://zixn.ru/plagin-zakazat-v-odin-klik-dlya-woocommerce.html 6 6 * Description: Buy in one click for WooCommerce. The best plugin that adds to your online store purchase button in one click 7 * Version: 2.2. 47 * Version: 2.2.5 8 8 * Author: Djo 9 9 * Author URI: https://zixn.ru -
buy-one-click-woocommerce/tags/2.2.5/js/form.js
r2774363 r2919599 125 125 jQuery(document).on('click', 'button.clickBuyButton', function (e) { 126 126 e.preventDefault(); 127 varself = jQuery(this);127 let self = jQuery(this); 128 128 if(jQuery(self).hasClass('disabled')){ 129 129 return; 130 130 } 131 var zixnAjaxUrl = getAjaxUrl(); 132 var butObj = 'body'; 133 // var butObj = self.parent(); 134 135 var button = jQuery(this); 136 137 var urlpost = window.location.href; 138 var productid = jQuery(this).attr('data-productid'); 139 var action = 'getViewForm'; 140 var variation_selected = 0; 141 var variation_attr = ''; 131 let button = jQuery(this); 132 let urlpost = window.location.href; 133 let productid = jQuery(this).attr('data-productid'); 134 let action = 'getViewForm'; 135 let variation_selected = 0; 136 let variation_attr = ''; 142 137 143 138 jQuery(button).addClass('running'); … … 153 148 jQuery.ajax({ 154 149 type: "POST", 155 url: zixnAjaxUrl, 156 // async: false, 150 url: getAjaxUrl(), 157 151 data: { 158 152 action: action, … … 171 165 } 172 166 jQuery('#formOrderOneClick').remove(); 173 jQuery( butObj).append(response.data);167 jQuery('body').append(response.data); 174 168 jQuery('.popup, .overlay').css('opacity', '1'); 175 169 jQuery('.popup, .overlay').css('visibility', 'visible'); … … 181 175 buyone_click_body_scroll(); 182 176 if (typeof buyone_ajax.callback_after_clicking_on_button !== 'undefined') { 183 varcallback = new Function(buyone_ajax.callback_after_clicking_on_button);177 const callback = new Function(buyone_ajax.callback_after_clicking_on_button); 184 178 callback(); 185 179 } 180 }, 181 error: function (response) { 182 186 183 } 187 184 }); … … 221 218 buyone_click_body_scroll(); 222 219 if (typeof buyone_ajax.callback_after_clicking_on_button !== 'undefined') { 223 varcallback = new Function(buyone_ajax.callback_after_clicking_on_button);220 const callback = new Function(buyone_ajax.callback_after_clicking_on_button); 224 221 callback(); 225 222 } -
buy-one-click-woocommerce/tags/2.2.5/readme.txt
r2864638 r2919599 4 4 Tags: woocommerce, ecommerce, mode catalog, buy one click, buy now, add to cart, buy now button, buttons 5 5 Requires at least: 5.0 6 Tested up to: 6. 17 Stable tag: 5. 76 Tested up to: 6.2 7 Stable tag: 5.9 8 8 Requires PHP: 7.4 9 WC requires at least: 4.710 WC tested up to: 6.19 WC requires at least: 5.0 10 WC tested up to: 7.7 11 11 License: GPLv2 or later 12 12 License URI: http://www.apache.org/licenses/ … … 73 73 74 74 == Changelog == 75 = 2.2.5 = 76 * Added polylang support for multilingual sites 77 * Added plugin "Woo Discount Rules" support for product pricing 75 78 = 2.2.4 = 76 79 * Improved compatibility with the plugin "coderun-buy-one-click-woocommerce-variations" -
buy-one-click-woocommerce/tags/2.2.5/src/Controller/FormController.php
r2796162 r2919599 11 11 use Coderun\BuyOneClick\Templates\Elements\Factory\QuantityFactory; 12 12 use Coderun\BuyOneClick\Templates\QuickOrderFormFactory; 13 use Coderun\BuyOneClick\Utils\Product as ProductUtils; 13 14 14 15 use function add_action; … … 73 74 'productId' => $product->get_id()?? '', 74 75 'productName' => $product->get_name()?? '', 75 'productPrice' => $product->get_price() ?? '',76 'productPrice' => ProductUtils::getProductPrice($product), 76 77 'productPriceHtml' => $product->get_price_html() ?? '', 77 78 'productCount' => 1, -
buy-one-click-woocommerce/tags/2.2.5/src/Controller/OrderController.php
r2864638 r2919599 27 27 use Coderun\BuyOneClick\Utils\Hooks; 28 28 use Coderun\BuyOneClick\Utils\Sms as SmsUtils; 29 use Coderun\BuyOneClick\Utils\Translation; 29 30 use Coderun\BuyOneClick\ValueObject\FieldNameViaType; 30 31 use Coderun\BuyOneClick\ValueObject\OrderForm; … … 168 169 $orderResponse = new OrderResponse(); 169 170 $orderResponse->setMessage(__('The order has been sent', 'coderun-oneclickwoo')); 170 $orderResponse->setResult( $this->commonOptions->getSubmittingFormMessageSuccess());171 $orderResponse->setResult(Translation::translate($this->commonOptions->getSubmittingFormMessageSuccess())); 171 172 $orderResponse->setProducts([new Product($orderForm)]); 172 173 $orderResponse->setOrderUuid($orderForm->getOrderUuid()); -
buy-one-click-woocommerce/tags/2.2.5/src/Core.php
r2864638 r2919599 6 6 use Coderun\BuyOneClick\Constant\Pages; 7 7 use Coderun\BuyOneClick\Constant\ShortCodes as ShortCodesConst; 8 use Coderun\BuyOneClick\Constant\TranslationString; 8 9 use Coderun\BuyOneClick\Controller\Factory\AdminControllerFactory; 9 10 use Coderun\BuyOneClick\Controller\Factory\CartControllerFactory; … … 17 18 use Coderun\BuyOneClick\Service\Factory\ShortCodesFactory; 18 19 use Coderun\BuyOneClick\Utils\Hooks; 20 use Coderun\BuyOneClick\Utils\Translation; 19 21 use Exception; 20 22 use WC_Product; … … 139 141 add_action( 140 142 'init', 143 [Translation::class, 'registrationTranslate'] 144 ); 145 add_action( 146 'init', 147 function (): void { 148 Translation::registrationTranslateByOptions($this->commonOptions); 149 } 150 ); 151 add_action( 152 'init', 141 153 function (): void { 142 154 do_action('buy_one_click_woocommerce_start_load_core'); … … 189 201 } 190 202 ); 203 add_filter('gettext', function ($translation, $text, $domain) { 204 if ($domain !== 'coderun-oneclickwoo' || !function_exists('pll__')) { 205 return $translation; 206 } 207 if (!in_array($text, TranslationString::all())) { 208 return $translation; 209 } 210 return Translation::translate($text); 211 }, 10, 3); 191 212 } 192 213 … … 313 334 $variables['after_submit_form'] = $this->commonOptions->getUrlRedirectAddress(); // 4 Редирект на страницу после нажатия на кнопку в форме 314 335 } 315 $variables['after_message_form'] = $this->commonOptions->getSubmittingFormMessageSuccess();336 $variables['after_message_form'] = Translation::translate($this->commonOptions->getSubmittingFormMessageSuccess()); 316 337 } 317 338 if ($this->marketingOptions->getAfterClickingOnButton()) { -
buy-one-click-woocommerce/tags/2.2.5/src/Options/General.php
r2774363 r2919599 1367 1367 return $this; 1368 1368 } 1369 1370 /** 1371 * Поля которые можно переводить 1372 * 1373 * @return array 1374 */ 1375 public function getTextsForTranslation(): array 1376 { 1377 return [ 1378 $this->getDescriptionForFieldComment(), 1379 $this->getDescriptionConsentToProcessing(), 1380 $this->getDescriptionForFieldEmail(), 1381 $this->getDescriptionForFieldFiles(), 1382 $this->getDescriptionForFieldFormatPhone(), 1383 $this->getDescriptionForFieldName(), 1384 $this->getDescriptionOfPreOrderButton(), 1385 $this->getNameButton(), 1386 $this->getDescriptionForFieldOrderButton(), 1387 $this->getMessageAfterSubmittingForm(), 1388 $this->getSubmittingFormMessageSuccess(), 1389 $this->getFormSubmissionLimitMessage(), 1390 ]; 1391 } 1369 1392 } -
buy-one-click-woocommerce/tags/2.2.5/src/Repository/Order.php
r2864638 r2919599 6 6 use Coderun\BuyOneClick\Hydrator\CommonHydrator; 7 7 use Coderun\BuyOneClick\Utils\Hooks; 8 use Coderun\BuyOneClick\Utils\Product as ProductUtils; 8 9 use Exception; 9 10 use WC_Order; … … 68 69 'variation_id' => $params['product_id'], 69 70 'variation' => $product->is_type('variation') ? $product->get_attributes() : [], 70 'subtotal' => wc_get_price_excluding_tax($product, ['qty' => $params['qty']]),71 'total' => wc_get_price_excluding_tax($product, ['qty' => $params['qty']]),71 'subtotal' => ProductUtils::getProductPrice($product) * intval($params['qty']), 72 'total' => ProductUtils::getProductPrice($product) * intval($params['qty']), 72 73 'quantity' => $params['qty'], 73 74 ]; -
buy-one-click-woocommerce/tags/2.2.5/src/Service/Button.php
r2864638 r2919599 5 5 namespace Coderun\BuyOneClick\Service; 6 6 7 use Coderun\BuyOneClick\Common\ObjectWithConstantState;8 7 use Coderun\BuyOneClick\Core; 9 8 use Coderun\BuyOneClick\Options\General as GeneralOptions; … … 14 13 use Coderun\BuyOneClick\Utils\Hooks; 15 14 use Coderun\BuyOneClick\Utils\Product as ProductUtils; 15 use Coderun\BuyOneClick\Utils\Translation; 16 16 use Exception; 17 17 … … 52 52 { 53 53 if ($this->commonOptions->getPositionButton()) { 54 $name = self::getButtonName();54 $name = $this->getButtonName(); 55 55 $productId = ProductUtils::getProductId(); 56 56 if (isset($params['id']) && !empty($params['id'])) { … … 108 108 'productName' => $params->name, 109 109 'productPriceHtml' => $params->priceWithCurrency, 110 'buttonName' => $this->commonOptions->getNameButton(),110 'buttonName' => Translation::translate($this->commonOptions->getNameButton()), 111 111 'inlineStyle' => '', 112 112 'inlineScript' => '', … … 137 137 138 138 if (ProductUtils::getProductId() === 0 || !$this->commonOptions->isEnableWorkWithRemainingItems()) { 139 return $defaultName;139 return Translation::translate($defaultName); 140 140 } 141 141 $stockStatus = get_post_meta(ProductUtils::getProductId(), '_stock_status', true); … … 144 144 //onbackorder - в не выполненом заказе 145 145 146 return $stockStatus === 'outofstock' ? $name : $defaultName;146 return Translation::translate($stockStatus === 'outofstock' ? $name : $defaultName); 147 147 } 148 148 -
buy-one-click-woocommerce/tags/2.2.5/src/Utils/Product.php
r2774363 r2919599 5 5 namespace Coderun\BuyOneClick\Utils; 6 6 7 use Throwable; 7 8 use WC_Product; 9 10 use function class_exists; 11 use function is_array; 12 use function method_exists; 8 13 9 14 /** … … 30 35 return $productId; 31 36 } 37 38 /** 39 * Цена товара с учётом сторонних дополнений 40 * 41 * @param $product 42 * @param int $quantity 43 * 44 * @return mixed|string 45 */ 46 public static function getProductPrice($product, $quantity = 1) 47 { 48 if (!$product instanceof WC_Product) { 49 return ''; 50 } 51 $prices = []; 52 try { 53 // plugin - Woo Discount Rules 54 if (class_exists('\Wdr\App\Controllers\ManageDiscount') 55 && method_exists('Wdr\App\Controllers\ManageDiscount', 'calculateInitialAndDiscountedPrice')) { 56 $prices = \Wdr\App\Controllers\ManageDiscount::calculateInitialAndDiscountedPrice($product, $quantity); 57 } 58 } catch (Throwable $e) { 59 // ignore errors 60 } 61 62 if (is_array($prices) && !empty($prices['discounted_price'])) { 63 return $prices['discounted_price']; 64 } 65 66 return $product->get_price() ?? ''; 67 } 32 68 } -
buy-one-click-woocommerce/tags/2.2.5/templates/forms/customOrderButton.php
r2774363 r2919599 20 20 data-price="<?php echo $fields->productPrice; ?>" 21 21 data-priceHtml="<?php echo $fields->productPriceHtml; ?>"> 22 <span><?php echo $fields->buttonName; ?></span>22 <span><?php echo \Coderun\BuyOneClick\Utils\Translation::translate($fields->buttonName); ?></span> 23 23 <div style="font-size:14px" class="ld ld-ring ld-cycle"></div> 24 24 </button> -
buy-one-click-woocommerce/tags/2.2.5/templates/forms/file_uploader.php
r2747271 r2919599 18 18 <label for="upload_file_form" class="btn btn-tertiary js-labelFile"> 19 19 <i class="icon fa fa-check"></i> 20 <span class="js-fileName"><?php echo $render->getCommonOptions()->getDescriptionForFieldFiles(); ?></span>20 <span class="js-fileName"><?php echo \Coderun\BuyOneClick\Utils\Translation::translate($render->getCommonOptions()->getDescriptionForFieldFiles()); ?></span> 21 21 </label> 22 22 </div> -
buy-one-click-woocommerce/tags/2.2.5/templates/forms/orderButton.php
r2763482 r2919599 17 17 data-variation_id="<?php echo $fields->variationId; ?>" 18 18 data-productid="<?php echo $fields->productId; ?>"> 19 <span> <?php echo $fields->buttonName; ?></span>19 <span> <?php echo \Coderun\BuyOneClick\Utils\Translation::translate($fields->buttonName); ?></span> 20 20 <div style="font-size:14px" class="ld ld-ring ld-cycle"></div> 21 21 </button> -
buy-one-click-woocommerce/tags/2.2.5/templates/forms/order_form.php
r2774363 r2919599 1 1 <?php 2 3 use Coderun\BuyOneClick\Utils\Translation; 4 2 5 if (!defined('ABSPATH')) { 3 6 exit; … … 17 20 <div class="close_order <?php echo $fields->templateStyle ? 'button' : '' ?>">x</div> 18 21 <form id="buyoneclick_form_order" class="b1c-form" method="post" action="#"> 19 <h2><?php echo $commonOptions->getNameButton(); ?></h2>22 <h2><?php echo Translation::translate($commonOptions->getNameButton()); ?></h2> 20 23 <?php if ($commonOptions->isEnableProductInformation()) { ?> 21 24 <div class="table-wrap"> … … 56 59 57 60 <?php if ($commonOptions->isEnableFieldWithName()) { ?> 58 <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?>" type="text" <?php ?> placeholder="<?php echo $commonOptions->getDescriptionForFieldName(); ?>" name="txtname">61 <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?>" type="text" <?php ?> placeholder="<?php echo Translation::translate($commonOptions->getDescriptionForFieldName()); ?>" name="txtname"> 59 62 <?php } ?> 60 63 <?php if ($commonOptions->isEnableFieldWithPhone()) { ?> 61 <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?> " type="tel" <?php ?> placeholder="<?php echo $commonOptions->getDescriptionForFieldPhone(); ?>" name="txtphone">64 <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?> " type="tel" <?php ?> placeholder="<?php echo Translation::translate($commonOptions->getDescriptionForFieldPhone()); ?>" name="txtphone"> 62 65 <p class="phoneFormat"><?php 63 66 if (!empty($commonOptions->getDescriptionForFieldFormatPhone())) { … … 67 70 <?php } ?> 68 71 <?php if ($commonOptions->isEnableFieldWithEmail()) { ?> 69 <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?> " type="email" <?php ?> placeholder="<?php echo $commonOptions->getDescriptionForFieldEmail(); ?>" name="txtemail">72 <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?> " type="email" <?php ?> placeholder="<?php echo Translation::translate($commonOptions->getDescriptionForFieldEmail()); ?>" name="txtemail"> 70 73 <?php } ?> 71 74 <?php if ($commonOptions->isEnableFieldWithComment()) { ?> 72 <textarea class="buymessage buyvalide" <?php ?> name="message" placeholder="<?php echo $commonOptions->getDescriptionForFieldComment(); ?>" rows="2" value=""></textarea>75 <textarea class="buymessage buyvalide" <?php ?> name="message" placeholder="<?php echo Translation::translate($commonOptions->getDescriptionForFieldComment()); ?>" rows="2" value=""></textarea> 73 76 <?php } ?> 74 77 … … 76 79 <p> 77 80 <input type="checkbox" name="conset_personal_data"> 78 <?php echo $commonOptions->getDescriptionConsentToProcessing(); ?>81 <?php echo Translation::translate($commonOptions->getDescriptionConsentToProcessing()); ?> 79 82 </p> 80 83 <?php } ?> … … 105 108 class="button alt buyButtonOkForm ld-ext-left" 106 109 name="btnsend"> 107 <span> <?php echo $commonOptions->getDescriptionForFieldOrderButton(); ?></span>110 <span> <?php echo Translation::translate($commonOptions->getDescriptionForFieldOrderButton()); ?></span> 108 111 <div style="font-size:14px" class="ld ld-ring ld-cycle"></div> 109 112 </button> … … 118 121 <div class = "popummessage"> 119 122 <div class="close_message">x</div> 120 <?php echo $commonOptions->getMessageAfterSubmittingForm(); ?>123 <?php echo Translation::translate($commonOptions->getMessageAfterSubmittingForm()); ?> 121 124 </div> 122 125 <?php -
buy-one-click-woocommerce/trunk/buycli-index.php
r2864638 r2919599 5 5 * Plugin URI: http://zixn.ru/plagin-zakazat-v-odin-klik-dlya-woocommerce.html 6 6 * Description: Buy in one click for WooCommerce. The best plugin that adds to your online store purchase button in one click 7 * Version: 2.2. 47 * Version: 2.2.5 8 8 * Author: Djo 9 9 * Author URI: https://zixn.ru -
buy-one-click-woocommerce/trunk/js/form.js
r2774363 r2919599 125 125 jQuery(document).on('click', 'button.clickBuyButton', function (e) { 126 126 e.preventDefault(); 127 varself = jQuery(this);127 let self = jQuery(this); 128 128 if(jQuery(self).hasClass('disabled')){ 129 129 return; 130 130 } 131 var zixnAjaxUrl = getAjaxUrl(); 132 var butObj = 'body'; 133 // var butObj = self.parent(); 134 135 var button = jQuery(this); 136 137 var urlpost = window.location.href; 138 var productid = jQuery(this).attr('data-productid'); 139 var action = 'getViewForm'; 140 var variation_selected = 0; 141 var variation_attr = ''; 131 let button = jQuery(this); 132 let urlpost = window.location.href; 133 let productid = jQuery(this).attr('data-productid'); 134 let action = 'getViewForm'; 135 let variation_selected = 0; 136 let variation_attr = ''; 142 137 143 138 jQuery(button).addClass('running'); … … 153 148 jQuery.ajax({ 154 149 type: "POST", 155 url: zixnAjaxUrl, 156 // async: false, 150 url: getAjaxUrl(), 157 151 data: { 158 152 action: action, … … 171 165 } 172 166 jQuery('#formOrderOneClick').remove(); 173 jQuery( butObj).append(response.data);167 jQuery('body').append(response.data); 174 168 jQuery('.popup, .overlay').css('opacity', '1'); 175 169 jQuery('.popup, .overlay').css('visibility', 'visible'); … … 181 175 buyone_click_body_scroll(); 182 176 if (typeof buyone_ajax.callback_after_clicking_on_button !== 'undefined') { 183 varcallback = new Function(buyone_ajax.callback_after_clicking_on_button);177 const callback = new Function(buyone_ajax.callback_after_clicking_on_button); 184 178 callback(); 185 179 } 180 }, 181 error: function (response) { 182 186 183 } 187 184 }); … … 221 218 buyone_click_body_scroll(); 222 219 if (typeof buyone_ajax.callback_after_clicking_on_button !== 'undefined') { 223 varcallback = new Function(buyone_ajax.callback_after_clicking_on_button);220 const callback = new Function(buyone_ajax.callback_after_clicking_on_button); 224 221 callback(); 225 222 } -
buy-one-click-woocommerce/trunk/readme.txt
r2864638 r2919599 4 4 Tags: woocommerce, ecommerce, mode catalog, buy one click, buy now, add to cart, buy now button, buttons 5 5 Requires at least: 5.0 6 Tested up to: 6. 17 Stable tag: 5. 76 Tested up to: 6.2 7 Stable tag: 5.9 8 8 Requires PHP: 7.4 9 WC requires at least: 4.710 WC tested up to: 6.19 WC requires at least: 5.0 10 WC tested up to: 7.7 11 11 License: GPLv2 or later 12 12 License URI: http://www.apache.org/licenses/ … … 73 73 74 74 == Changelog == 75 = 2.2.5 = 76 * Added polylang support for multilingual sites 77 * Added plugin "Woo Discount Rules" support for product pricing 75 78 = 2.2.4 = 76 79 * Improved compatibility with the plugin "coderun-buy-one-click-woocommerce-variations" -
buy-one-click-woocommerce/trunk/src/Controller/FormController.php
r2796162 r2919599 11 11 use Coderun\BuyOneClick\Templates\Elements\Factory\QuantityFactory; 12 12 use Coderun\BuyOneClick\Templates\QuickOrderFormFactory; 13 use Coderun\BuyOneClick\Utils\Product as ProductUtils; 13 14 14 15 use function add_action; … … 73 74 'productId' => $product->get_id()?? '', 74 75 'productName' => $product->get_name()?? '', 75 'productPrice' => $product->get_price() ?? '',76 'productPrice' => ProductUtils::getProductPrice($product), 76 77 'productPriceHtml' => $product->get_price_html() ?? '', 77 78 'productCount' => 1, -
buy-one-click-woocommerce/trunk/src/Controller/OrderController.php
r2864638 r2919599 27 27 use Coderun\BuyOneClick\Utils\Hooks; 28 28 use Coderun\BuyOneClick\Utils\Sms as SmsUtils; 29 use Coderun\BuyOneClick\Utils\Translation; 29 30 use Coderun\BuyOneClick\ValueObject\FieldNameViaType; 30 31 use Coderun\BuyOneClick\ValueObject\OrderForm; … … 168 169 $orderResponse = new OrderResponse(); 169 170 $orderResponse->setMessage(__('The order has been sent', 'coderun-oneclickwoo')); 170 $orderResponse->setResult( $this->commonOptions->getSubmittingFormMessageSuccess());171 $orderResponse->setResult(Translation::translate($this->commonOptions->getSubmittingFormMessageSuccess())); 171 172 $orderResponse->setProducts([new Product($orderForm)]); 172 173 $orderResponse->setOrderUuid($orderForm->getOrderUuid()); -
buy-one-click-woocommerce/trunk/src/Core.php
r2864638 r2919599 6 6 use Coderun\BuyOneClick\Constant\Pages; 7 7 use Coderun\BuyOneClick\Constant\ShortCodes as ShortCodesConst; 8 use Coderun\BuyOneClick\Constant\TranslationString; 8 9 use Coderun\BuyOneClick\Controller\Factory\AdminControllerFactory; 9 10 use Coderun\BuyOneClick\Controller\Factory\CartControllerFactory; … … 17 18 use Coderun\BuyOneClick\Service\Factory\ShortCodesFactory; 18 19 use Coderun\BuyOneClick\Utils\Hooks; 20 use Coderun\BuyOneClick\Utils\Translation; 19 21 use Exception; 20 22 use WC_Product; … … 139 141 add_action( 140 142 'init', 143 [Translation::class, 'registrationTranslate'] 144 ); 145 add_action( 146 'init', 147 function (): void { 148 Translation::registrationTranslateByOptions($this->commonOptions); 149 } 150 ); 151 add_action( 152 'init', 141 153 function (): void { 142 154 do_action('buy_one_click_woocommerce_start_load_core'); … … 189 201 } 190 202 ); 203 add_filter('gettext', function ($translation, $text, $domain) { 204 if ($domain !== 'coderun-oneclickwoo' || !function_exists('pll__')) { 205 return $translation; 206 } 207 if (!in_array($text, TranslationString::all())) { 208 return $translation; 209 } 210 return Translation::translate($text); 211 }, 10, 3); 191 212 } 192 213 … … 313 334 $variables['after_submit_form'] = $this->commonOptions->getUrlRedirectAddress(); // 4 Редирект на страницу после нажатия на кнопку в форме 314 335 } 315 $variables['after_message_form'] = $this->commonOptions->getSubmittingFormMessageSuccess();336 $variables['after_message_form'] = Translation::translate($this->commonOptions->getSubmittingFormMessageSuccess()); 316 337 } 317 338 if ($this->marketingOptions->getAfterClickingOnButton()) { -
buy-one-click-woocommerce/trunk/src/Options/General.php
r2774363 r2919599 1367 1367 return $this; 1368 1368 } 1369 1370 /** 1371 * Поля которые можно переводить 1372 * 1373 * @return array 1374 */ 1375 public function getTextsForTranslation(): array 1376 { 1377 return [ 1378 $this->getDescriptionForFieldComment(), 1379 $this->getDescriptionConsentToProcessing(), 1380 $this->getDescriptionForFieldEmail(), 1381 $this->getDescriptionForFieldFiles(), 1382 $this->getDescriptionForFieldFormatPhone(), 1383 $this->getDescriptionForFieldName(), 1384 $this->getDescriptionOfPreOrderButton(), 1385 $this->getNameButton(), 1386 $this->getDescriptionForFieldOrderButton(), 1387 $this->getMessageAfterSubmittingForm(), 1388 $this->getSubmittingFormMessageSuccess(), 1389 $this->getFormSubmissionLimitMessage(), 1390 ]; 1391 } 1369 1392 } -
buy-one-click-woocommerce/trunk/src/Repository/Order.php
r2864638 r2919599 6 6 use Coderun\BuyOneClick\Hydrator\CommonHydrator; 7 7 use Coderun\BuyOneClick\Utils\Hooks; 8 use Coderun\BuyOneClick\Utils\Product as ProductUtils; 8 9 use Exception; 9 10 use WC_Order; … … 68 69 'variation_id' => $params['product_id'], 69 70 'variation' => $product->is_type('variation') ? $product->get_attributes() : [], 70 'subtotal' => wc_get_price_excluding_tax($product, ['qty' => $params['qty']]),71 'total' => wc_get_price_excluding_tax($product, ['qty' => $params['qty']]),71 'subtotal' => ProductUtils::getProductPrice($product) * intval($params['qty']), 72 'total' => ProductUtils::getProductPrice($product) * intval($params['qty']), 72 73 'quantity' => $params['qty'], 73 74 ]; -
buy-one-click-woocommerce/trunk/src/Service/Button.php
r2864638 r2919599 5 5 namespace Coderun\BuyOneClick\Service; 6 6 7 use Coderun\BuyOneClick\Common\ObjectWithConstantState;8 7 use Coderun\BuyOneClick\Core; 9 8 use Coderun\BuyOneClick\Options\General as GeneralOptions; … … 14 13 use Coderun\BuyOneClick\Utils\Hooks; 15 14 use Coderun\BuyOneClick\Utils\Product as ProductUtils; 15 use Coderun\BuyOneClick\Utils\Translation; 16 16 use Exception; 17 17 … … 52 52 { 53 53 if ($this->commonOptions->getPositionButton()) { 54 $name = self::getButtonName();54 $name = $this->getButtonName(); 55 55 $productId = ProductUtils::getProductId(); 56 56 if (isset($params['id']) && !empty($params['id'])) { … … 108 108 'productName' => $params->name, 109 109 'productPriceHtml' => $params->priceWithCurrency, 110 'buttonName' => $this->commonOptions->getNameButton(),110 'buttonName' => Translation::translate($this->commonOptions->getNameButton()), 111 111 'inlineStyle' => '', 112 112 'inlineScript' => '', … … 137 137 138 138 if (ProductUtils::getProductId() === 0 || !$this->commonOptions->isEnableWorkWithRemainingItems()) { 139 return $defaultName;139 return Translation::translate($defaultName); 140 140 } 141 141 $stockStatus = get_post_meta(ProductUtils::getProductId(), '_stock_status', true); … … 144 144 //onbackorder - в не выполненом заказе 145 145 146 return $stockStatus === 'outofstock' ? $name : $defaultName;146 return Translation::translate($stockStatus === 'outofstock' ? $name : $defaultName); 147 147 } 148 148 -
buy-one-click-woocommerce/trunk/src/Utils/Product.php
r2774363 r2919599 5 5 namespace Coderun\BuyOneClick\Utils; 6 6 7 use Throwable; 7 8 use WC_Product; 9 10 use function class_exists; 11 use function is_array; 12 use function method_exists; 8 13 9 14 /** … … 30 35 return $productId; 31 36 } 37 38 /** 39 * Цена товара с учётом сторонних дополнений 40 * 41 * @param $product 42 * @param int $quantity 43 * 44 * @return mixed|string 45 */ 46 public static function getProductPrice($product, $quantity = 1) 47 { 48 if (!$product instanceof WC_Product) { 49 return ''; 50 } 51 $prices = []; 52 try { 53 // plugin - Woo Discount Rules 54 if (class_exists('\Wdr\App\Controllers\ManageDiscount') 55 && method_exists('Wdr\App\Controllers\ManageDiscount', 'calculateInitialAndDiscountedPrice')) { 56 $prices = \Wdr\App\Controllers\ManageDiscount::calculateInitialAndDiscountedPrice($product, $quantity); 57 } 58 } catch (Throwable $e) { 59 // ignore errors 60 } 61 62 if (is_array($prices) && !empty($prices['discounted_price'])) { 63 return $prices['discounted_price']; 64 } 65 66 return $product->get_price() ?? ''; 67 } 32 68 } -
buy-one-click-woocommerce/trunk/templates/forms/customOrderButton.php
r2774363 r2919599 20 20 data-price="<?php echo $fields->productPrice; ?>" 21 21 data-priceHtml="<?php echo $fields->productPriceHtml; ?>"> 22 <span><?php echo $fields->buttonName; ?></span>22 <span><?php echo \Coderun\BuyOneClick\Utils\Translation::translate($fields->buttonName); ?></span> 23 23 <div style="font-size:14px" class="ld ld-ring ld-cycle"></div> 24 24 </button> -
buy-one-click-woocommerce/trunk/templates/forms/file_uploader.php
r2747271 r2919599 18 18 <label for="upload_file_form" class="btn btn-tertiary js-labelFile"> 19 19 <i class="icon fa fa-check"></i> 20 <span class="js-fileName"><?php echo $render->getCommonOptions()->getDescriptionForFieldFiles(); ?></span>20 <span class="js-fileName"><?php echo \Coderun\BuyOneClick\Utils\Translation::translate($render->getCommonOptions()->getDescriptionForFieldFiles()); ?></span> 21 21 </label> 22 22 </div> -
buy-one-click-woocommerce/trunk/templates/forms/orderButton.php
r2763482 r2919599 17 17 data-variation_id="<?php echo $fields->variationId; ?>" 18 18 data-productid="<?php echo $fields->productId; ?>"> 19 <span> <?php echo $fields->buttonName; ?></span>19 <span> <?php echo \Coderun\BuyOneClick\Utils\Translation::translate($fields->buttonName); ?></span> 20 20 <div style="font-size:14px" class="ld ld-ring ld-cycle"></div> 21 21 </button> -
buy-one-click-woocommerce/trunk/templates/forms/order_form.php
r2774363 r2919599 1 1 <?php 2 3 use Coderun\BuyOneClick\Utils\Translation; 4 2 5 if (!defined('ABSPATH')) { 3 6 exit; … … 17 20 <div class="close_order <?php echo $fields->templateStyle ? 'button' : '' ?>">x</div> 18 21 <form id="buyoneclick_form_order" class="b1c-form" method="post" action="#"> 19 <h2><?php echo $commonOptions->getNameButton(); ?></h2>22 <h2><?php echo Translation::translate($commonOptions->getNameButton()); ?></h2> 20 23 <?php if ($commonOptions->isEnableProductInformation()) { ?> 21 24 <div class="table-wrap"> … … 56 59 57 60 <?php if ($commonOptions->isEnableFieldWithName()) { ?> 58 <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?>" type="text" <?php ?> placeholder="<?php echo $commonOptions->getDescriptionForFieldName(); ?>" name="txtname">61 <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?>" type="text" <?php ?> placeholder="<?php echo Translation::translate($commonOptions->getDescriptionForFieldName()); ?>" name="txtname"> 59 62 <?php } ?> 60 63 <?php if ($commonOptions->isEnableFieldWithPhone()) { ?> 61 <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?> " type="tel" <?php ?> placeholder="<?php echo $commonOptions->getDescriptionForFieldPhone(); ?>" name="txtphone">64 <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?> " type="tel" <?php ?> placeholder="<?php echo Translation::translate($commonOptions->getDescriptionForFieldPhone()); ?>" name="txtphone"> 62 65 <p class="phoneFormat"><?php 63 66 if (!empty($commonOptions->getDescriptionForFieldFormatPhone())) { … … 67 70 <?php } ?> 68 71 <?php if ($commonOptions->isEnableFieldWithEmail()) { ?> 69 <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?> " type="email" <?php ?> placeholder="<?php echo $commonOptions->getDescriptionForFieldEmail(); ?>" name="txtemail">72 <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?> " type="email" <?php ?> placeholder="<?php echo Translation::translate($commonOptions->getDescriptionForFieldEmail()); ?>" name="txtemail"> 70 73 <?php } ?> 71 74 <?php if ($commonOptions->isEnableFieldWithComment()) { ?> 72 <textarea class="buymessage buyvalide" <?php ?> name="message" placeholder="<?php echo $commonOptions->getDescriptionForFieldComment(); ?>" rows="2" value=""></textarea>75 <textarea class="buymessage buyvalide" <?php ?> name="message" placeholder="<?php echo Translation::translate($commonOptions->getDescriptionForFieldComment()); ?>" rows="2" value=""></textarea> 73 76 <?php } ?> 74 77 … … 76 79 <p> 77 80 <input type="checkbox" name="conset_personal_data"> 78 <?php echo $commonOptions->getDescriptionConsentToProcessing(); ?>81 <?php echo Translation::translate($commonOptions->getDescriptionConsentToProcessing()); ?> 79 82 </p> 80 83 <?php } ?> … … 105 108 class="button alt buyButtonOkForm ld-ext-left" 106 109 name="btnsend"> 107 <span> <?php echo $commonOptions->getDescriptionForFieldOrderButton(); ?></span>110 <span> <?php echo Translation::translate($commonOptions->getDescriptionForFieldOrderButton()); ?></span> 108 111 <div style="font-size:14px" class="ld ld-ring ld-cycle"></div> 109 112 </button> … … 118 121 <div class = "popummessage"> 119 122 <div class="close_message">x</div> 120 <?php echo $commonOptions->getMessageAfterSubmittingForm(); ?>123 <?php echo Translation::translate($commonOptions->getMessageAfterSubmittingForm()); ?> 121 124 </div> 122 125 <?php
Note: See TracChangeset
for help on using the changeset viewer.