Changeset 3767494
- Timestamp:
- 10/26/2026 11:39:47 PM (8 hours ago)
- Location:
- woocommerce-ajax-cart
- Files:
-
- 26 added
- 5 edited
-
tags/1.4.0 (added)
-
tags/1.4.0/assets (added)
-
tags/1.4.0/assets/wac-cart-block.js (added)
-
tags/1.4.0/assets/wac-side-cart.css (added)
-
tags/1.4.0/assets/wac-side-cart.js (added)
-
tags/1.4.0/assets/wooajaxcart.css (added)
-
tags/1.4.0/assets/wooajaxcart.js (added)
-
tags/1.4.0/common (added)
-
tags/1.4.0/common/MHCommon.php (added)
-
tags/1.4.0/common/MHNotice.php (added)
-
tags/1.4.0/common/MHSettings.php (added)
-
tags/1.4.0/common/assets (added)
-
tags/1.4.0/common/assets/admin-settings.css (added)
-
tags/1.4.0/common/assets/admin-settings.js (added)
-
tags/1.4.0/common/assets/alert.png (added)
-
tags/1.4.0/common/assets/youtube.png (added)
-
tags/1.4.0/i18n (added)
-
tags/1.4.0/i18n/languages (added)
-
tags/1.4.0/i18n/languages/woocommerce-ajax-cart.pot (added)
-
tags/1.4.0/readme.txt (added)
-
tags/1.4.0/templates (added)
-
tags/1.4.0/templates/wac-qty-select.php (added)
-
tags/1.4.0/wooajaxcart.php (added)
-
trunk/assets/wac-cart-block.js (added)
-
trunk/assets/wac-side-cart.css (added)
-
trunk/assets/wac-side-cart.js (added)
-
trunk/common/MHSettings.php (modified) (12 diffs)
-
trunk/common/assets/admin-settings.css (modified) (1 diff)
-
trunk/i18n/languages/woocommerce-ajax-cart.pot (modified) (7 diffs)
-
trunk/readme.txt (modified) (4 diffs)
-
trunk/wooajaxcart.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woocommerce-ajax-cart/trunk/common/MHSettings.php
r3757257 r3767494 198 198 199 199 ?> 200 <div class="wrap"> 201 <div class="icon32"> 202 <br /> 203 </div> 204 <h2 class="nav-tab-wrapper"> 200 <div class="wrap mh-settings-wrap"> 201 <h1 class="mh-settings-title"> 205 202 <?php echo esc_html($title); ?> 206 </h 2>203 </h1> 207 204 <?php if ( $displayPremiumTab ): ?> 208 205 <?php $this->premium_alert_box(); ?> … … 248 245 ?> 249 246 <?php $this->form_header() ?> 247 <div class="mh-card"> 250 248 <?php foreach ( $settings as $name => $conf ): ?> 251 < div class="conf">252 < ?php if ( empty($conf['depends_on']) ): ?>249 <?php if ( empty($conf['depends_on']) ): ?> 250 <div class="conf conf-<?php echo esc_attr($conf['type']); ?>"> 253 251 <?php $this->render_field($settings, $name, $conf) ?> 254 < ?php endif; ?>255 < /div>252 </div> 253 <?php endif; ?> 256 254 <?php endforeach; ?> 255 </div> 257 256 <?php do_action("mh_{$this->pluginAbbrev}_after_tab", $normalizedTab); ?> 258 257 <?php $this->form_footer() ?> … … 321 320 <div class="mh-subconf"> 322 321 <?php foreach ( $dependants as $name => $conf ): ?> 323 <?php $this->render_field($settings, $name, $conf); ?> 324 <br/> 322 <div class="conf conf-<?php echo esc_attr($conf['type']); ?>"> 323 <?php $this->render_field($settings, $name, $conf); ?> 324 </div> 325 325 <?php endforeach; ?> 326 326 </div> … … 379 379 public function form_footer() { 380 380 ?> 381 < hr/>382 <input name="save" class="button-primary" type="submit" value="<?php echo esc_html__('Save settings', 'woocommerce-ajax-cart'); ?>" />383 <?php do_action("mh_{$this->pluginAbbrev}_admin_buttons"); ?>384 <input name="save" class="button" type="submit"381 <div class="mh-actions"> 382 <input name="save" class="button button-primary" type="submit" value="<?php echo esc_html__('Save settings', 'woocommerce-ajax-cart'); ?>" /> 383 <?php do_action("mh_{$this->pluginAbbrev}_admin_buttons"); ?> 384 <input name="save" class="button mh-reset" type="submit" 385 385 value="<?php echo esc_html__('Reset all settings', 'woocommerce-ajax-cart'); ?>" 386 386 onclick="return confirm('<?php echo esc_html__('Are you sure?', 'woocommerce-ajax-cart') ?>')"/> 387 </div> 387 388 </form> 388 389 <?php … … 533 534 ?> 534 535 <input type="hidden" name="<?php echo esc_attr($name) ?>" value="0" /> 535 <label >536 <label class="mh-check"> 536 537 <input type="checkbox" 537 538 <?php if ( $value === 'yes' ): ?>checked<?php endif; ?> 538 class=" <?php echo esc_attr($class) ?>"539 class="mh-switch <?php echo esc_attr($class) ?>" 539 540 name="<?php echo esc_attr($name) ?>"> 540 < ?php echo esc_html($label); ?>541 <span><?php echo esc_html($label); ?></span> 541 542 </label> 542 543 <?php … … 547 548 548 549 ?> 549 < ?php echo esc_html($label); ?>:550 <span class="mh-label"><?php echo esc_html($label); ?></span> 550 551 <input type="text" 551 552 value="<?php echo esc_attr($value); ?>" … … 559 560 560 561 ?> 561 < ?php echo esc_html($label); ?>:562 <span class="mh-label"><?php echo esc_html($label); ?></span> 562 563 <input type="number" 563 564 value="<?php echo esc_attr($value); ?>" … … 572 573 573 574 ?> 574 < ?php echo esc_html($label); ?>:575 <span class="mh-label"><?php echo esc_html($label); ?></span> 575 576 <input type="color" 576 577 value="<?php echo esc_attr($value); ?>" … … 583 584 584 585 ?> 585 < ?php echo esc_html($label); ?>:586 <span class="mh-label"><?php echo esc_html($label); ?></span> 586 587 <input type="date" 587 588 value="<?php echo esc_attr($value); ?>" … … 594 595 595 596 ?> 596 < ?php echo esc_html($label); ?>:597 <span class="mh-label"><?php echo esc_html($label); ?></span> 597 598 <select name="<?php echo esc_attr($name) ?>"> 598 599 <?php foreach ( (array) $options as $optVal => $optLabel ): ?> … … 609 610 610 611 ?> 611 <br/> 612 <?php echo esc_html($label); ?>: 613 <br/> 612 <span class="mh-label"><?php echo esc_html($label); ?></span> 614 613 <input type="hidden" name="<?php echo esc_attr($name); ?>" value=""/> 615 614 <select multiple="multiple" name="<?php echo esc_attr($name); ?>[]"> … … 628 627 629 628 ?> 630 <?php echo esc_html( $label ); ?>: 629 <span class="mh-label"><?php echo esc_html( $label ); ?></span> 630 <span class="mh-chips"> 631 631 <?php foreach ( $options as $key => $value ): ?> 632 <label ><input632 <label class="mh-chip"><input 633 633 name="<?php echo esc_attr($name); ?>[]" 634 634 value="<?php echo esc_attr( $key ); ?>" 635 635 <?php if ( in_array( $key, $values ) ): ?>checked="checked"<?php endif; ?> 636 636 type="checkbox"/><?php echo esc_html( $value ); ?></label> 637 638 637 <?php endforeach; ?> 638 </span> 639 639 <?php 640 640 } -
woocommerce-ajax-cart/trunk/common/assets/admin-settings.css
r2385280 r3767494 1 label {2 line-height:28px;3 }4 5 1 #footer-left,#footer-upgrade { 6 2 display: none; 7 3 } 8 4 9 .mh-subconf { 10 margin-left: 8px; 11 padding-left: 20px; 12 padding-bottom: 5px; 13 border-left: 1px solid lightgray; 14 border-bottom: 1px solid lightgray; 15 margin-top: 5px; 5 /* Settings page: a card of rows — the label in one column, its control in the 6 next; on/off settings are switches; a setting's sub-options sit in a tinted 7 panel under it. */ 8 .mh-settings-wrap { 9 max-width: 1200px; 10 } 11 12 .mh-settings-title { 13 font-size: 23px; 14 font-weight: 600; 15 margin: 4px 0 14px; 16 16 } 17 17 18 18 .mh-settings-page { 19 19 font-size: 14px; 20 margin: 1%; 20 margin: 0; 21 max-width: 920px; 22 } 23 24 .mh-card { 25 margin-top: 16px; 26 background: #fff; 27 border: 1px solid #dcdcde; 28 border-radius: 8px; 29 box-shadow: 0 1px 2px rgba(0, 0, 0, .04); 30 padding: 6px 24px; 21 31 } 22 32 23 33 .mh-settings-page .conf { 34 display: grid; 35 grid-template-columns: 240px minmax(0, 1fr); 36 align-items: center; 37 column-gap: 20px; 38 padding: 14px 0; 39 border-bottom: 1px solid #f0f0f1; 40 } 41 42 .mh-card > .conf:last-child { 43 border-bottom: 0; 44 } 45 46 .mh-settings-page .mh-label { 47 font-weight: 600; 48 color: #1d2327; 49 } 50 51 .mh-settings-page .conf > select, 52 .mh-settings-page .conf > input[type=text], 53 .mh-settings-page .conf > input[type=number], 54 .mh-settings-page .conf > input[type=date] { 55 justify-self: start; 56 min-width: 220px; 57 max-width: 100%; 58 min-height: 36px; 59 border-radius: 6px; 60 } 61 62 .mh-settings-page .conf > select[multiple] { 63 min-width: 260px; 64 min-height: 96px; 24 65 padding: 4px; 66 } 67 68 .mh-settings-page .conf > input[type=color] { 69 justify-self: start; 70 width: 56px; 71 height: 34px; 72 padding: 2px; 73 border: 1px solid #8c8f94; 74 border-radius: 6px; 75 background: #fff; 76 cursor: pointer; 77 } 78 79 /* On/off settings: the whole row is the switch's label */ 80 .mh-settings-page .conf-checkbox { 81 display: block; 82 } 83 84 .mh-check { 85 display: flex; 86 align-items: center; 87 gap: 14px; 88 cursor: pointer; 89 line-height: 1.4; 90 } 91 92 .mh-check > span { 93 color: #1d2327; 94 } 95 96 .mh-settings-page input.mh-switch[type=checkbox] { 97 appearance: none; 98 -webkit-appearance: none; 99 flex: 0 0 auto; 100 position: relative; 101 width: 40px; 102 height: 22px; 103 margin: 0; 104 border: 0; 105 border-radius: 22px; 106 background: #c3c4c7; 107 box-shadow: none; 108 cursor: pointer; 109 transition: background .15s; 110 } 111 112 .mh-settings-page input.mh-switch[type=checkbox]::before { 113 content: ''; 114 position: absolute; 115 top: 3px; 116 left: 3px; 117 width: 16px; 118 height: 16px; 119 margin: 0; 120 border-radius: 50%; 121 background: #fff; 122 box-shadow: 0 1px 2px rgba(0, 0, 0, .25); 123 transition: transform .15s; 124 } 125 126 .mh-settings-page input.mh-switch[type=checkbox]:checked { 127 background: var(--wp-admin-theme-color, #2271b1); 128 } 129 130 .mh-settings-page input.mh-switch[type=checkbox]:checked::before { 131 transform: translateX(18px); 132 } 133 134 .mh-settings-page input.mh-switch[type=checkbox]:focus-visible { 135 outline: 2px solid var(--wp-admin-theme-color, #2271b1); 136 outline-offset: 2px; 137 } 138 139 /* A setting's sub-options */ 140 .mh-subconf { 141 margin: 12px 0 0 54px; 142 padding: 2px 18px; 143 background: #f6f7f7; 144 border-radius: 6px; 145 } 146 147 .mh-subconf .conf { 148 padding: 10px 0; 149 border-bottom: 1px solid #e8e9ea; 150 grid-template-columns: 186px minmax(0, 1fr); 151 } 152 153 .mh-subconf .conf:last-child { 154 border-bottom: 0; 155 } 156 157 /* Several choices: chips */ 158 .mh-chips { 159 display: flex; 160 flex-wrap: wrap; 161 gap: 8px; 162 } 163 164 .mh-chip { 165 display: inline-flex; 166 align-items: center; 167 gap: 6px; 168 padding: 5px 12px; 169 border: 1px solid #c3c4c7; 170 border-radius: 999px; 171 background: #fff; 172 cursor: pointer; 173 line-height: 1.4; 174 } 175 176 .mh-chip input[type=checkbox] { 177 margin: 0; 178 } 179 180 .mh-chip:has(input:checked) { 181 border-color: var(--wp-admin-theme-color, #2271b1); 182 background: #f0f6fc; 183 color: var(--wp-admin-theme-color, #2271b1); 184 } 185 186 /* Save / reset */ 187 .mh-actions { 188 display: flex; 189 align-items: center; 190 gap: 10px; 191 margin-top: 18px; 192 } 193 194 .mh-actions .button { 195 min-height: 36px; 196 padding: 0 18px; 197 border-radius: 6px; 198 } 199 200 .mh-actions .mh-reset { 201 margin-left: auto; 202 } 203 204 @media (max-width: 782px) { 205 .mh-card { 206 padding: 4px 14px; 207 } 208 209 .mh-settings-page .conf, 210 .mh-subconf .conf { 211 grid-template-columns: minmax(0, 1fr); 212 row-gap: 8px; 213 } 214 215 .mh-subconf { 216 margin-left: 0; 217 } 25 218 } 26 219 -
woocommerce-ajax-cart/trunk/i18n/languages/woocommerce-ajax-cart.pot
r3757257 r3767494 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Ajax Cart for WooCommerce 1. 3.28\n"5 "Project-Id-Version: Ajax Cart for WooCommerce 1.4.0\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woocommerce-ajax-cart\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 2026-10-2 0T18:05:18+00:00\n"12 "POT-Creation-Date: 2026-10-26T23:39:09+00:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 14 "X-Generator: WP-CLI 2.12.0\n" … … 17 17 #. Plugin Name of the plugin 18 18 #: wooajaxcart.php 19 #: wooajaxcart.php:4 419 #: wooajaxcart.php:46 20 20 msgid "Ajax Cart for WooCommerce" 21 21 msgstr "" … … 69 69 msgstr "" 70 70 71 #: common/MHSettings.php:21 771 #: common/MHSettings.php:214 72 72 msgid "Get PRO" 73 73 msgstr "" … … 78 78 79 79 #. translators: %s: the plugin's review page 80 #: common/MHSettings.php:39 680 #: common/MHSettings.php:397 81 81 #, php-format 82 82 msgid "If you liked this plugin, please help us <a href=\"%s\" target=\"_blank\">giving a 5-star rate</a> on WordPress.org :)" … … 84 84 85 85 #. translators: 1: the plugin's name, 2: the premium tab's address 86 #: common/MHSettings.php:41 686 #: common/MHSettings.php:417 87 87 #, php-format 88 88 msgid "You're using a limited version of %1$s. For more features and better support, please <a href=\"%2$s\">consider the premium version</a>." 89 89 msgstr "" 90 90 91 #: common/MHSettings.php:51 691 #: common/MHSettings.php:517 92 92 msgid "Features included in PRO version" 93 93 msgstr "" 94 94 95 #: common/MHSettings.php:52 395 #: common/MHSettings.php:524 96 96 msgid "Buy on Gumroad" 97 97 msgstr "" … … 102 102 msgstr "" 103 103 104 #: wooajaxcart.php: 58104 #: wooajaxcart.php:60 105 105 msgid "Display -/+ buttons around product quantity input" 106 106 msgstr "" 107 107 108 #: wooajaxcart.php: 59109 #: wooajaxcart.php:6 5110 #: wooajaxcart.php:7 1111 #: wooajaxcart.php:8 0112 #: wooajaxcart.php: 86108 #: wooajaxcart.php:61 109 #: wooajaxcart.php:67 110 #: wooajaxcart.php:73 111 #: wooajaxcart.php:82 112 #: wooajaxcart.php:108 113 113 msgid "General" 114 114 msgstr "" 115 115 116 #: wooajaxcart.php:6 4116 #: wooajaxcart.php:66 117 117 msgid "Show item quantity as select instead numeric field" 118 118 msgstr "" 119 119 120 #: wooajaxcart.php:7 0120 #: wooajaxcart.php:72 121 121 msgid "Items to show on select" 122 122 msgstr "" 123 123 124 #: wooajaxcart.php: 79124 #: wooajaxcart.php:81 125 125 msgid "Show user confirmation when change item quantity to zero or empty" 126 126 msgstr "" 127 127 128 #: wooajaxcart.php:85 128 #: wooajaxcart.php:87 129 msgid "Enable the side cart: a cart drawer that slides in from the side, on every page but the cart and checkout" 130 msgstr "" 131 132 #: wooajaxcart.php:88 133 #: wooajaxcart.php:94 134 #: wooajaxcart.php:101 135 msgid "Side cart" 136 msgstr "" 137 138 #: wooajaxcart.php:93 139 msgid "Open the side cart when a product is added to the cart" 140 msgstr "" 141 142 #: wooajaxcart.php:100 143 msgid "Show a floating cart button with the item count" 144 msgstr "" 145 146 #: wooajaxcart.php:107 129 147 msgid "AJAX timeout in milliseconds to refresh the cart on change" 130 148 msgstr "" 131 149 132 #: wooajaxcart.php:127 150 #: wooajaxcart.php:160 151 #: wooajaxcart.php:209 152 msgid "Are you sure you want to remove this item from cart?" 153 msgstr "" 154 155 #: wooajaxcart.php:180 156 msgid "Open the cart" 157 msgstr "" 158 159 #: wooajaxcart.php:187 160 msgid "Cart" 161 msgstr "" 162 163 #: wooajaxcart.php:189 164 msgid "Your cart" 165 msgstr "" 166 167 #: wooajaxcart.php:190 168 msgid "Close the cart" 169 msgstr "" 170 171 #: wooajaxcart.php:208 133 172 msgid "Updating..." 134 173 msgstr "" 135 136 #: wooajaxcart.php:128137 msgid "Are you sure you want to remove this item from cart?"138 msgstr "" -
woocommerce-ajax-cart/trunk/readme.txt
r3757257 r3767494 1 1 === Ajax Cart for WooCommerce === 2 2 Contributors: moiseh 3 Tags: woocommerce, ajax, cart, s hipping3 Tags: woocommerce, ajax, cart, side cart, quantity 4 4 Requires at least: 5.0 5 5 Tested up to: 7.1 6 Stable tag: 1. 3.286 Stable tag: 1.4.0 7 7 License: GPLv2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html 9 9 10 Updates the WooCommerce cart totals with AJAX as soon as a quantity changes, without clicking "Update cart".10 AJAX cart for WooCommerce: totals update as soon as a quantity changes, plus a slide-in side cart that works with any theme. 11 11 12 12 == Description == 13 13 14 Ajax Cart for WooCommerce changes the default behavior of the WooCommerce cart page: when a buyer changes the quantity of a product, the totals are recalculated right away with AJAX, without clicking the "Update cart" button.14 Ajax Cart for WooCommerce makes buying smoother in two ways: 15 15 16 This improves the user experience when purchasing a product. No other hacks/code/theme changes is needed, this functionality is added when the plugin is activated. 16 * **On the classic cart page** (the `[woocommerce_cart]` shortcode most stores and classic themes use), totals are recalculated with AJAX as soon as a quantity changes — no "Update cart" click — with -/+ buttons around the quantity. 17 * **A side cart** (optional): a cart drawer that slides in from the side when a product is added, with a floating cart button — on classic and block themes alike, on every page but the cart and checkout. 18 19 On the newer **Cart block** (the default for stores created since WooCommerce 8.3), WooCommerce already updates quantities by itself; there the plugin adds a confirmation before an item is removed, and the side cart works the same. 20 21 No other hacks, code or theme changes are needed: the features are active as soon as the plugin is. 17 22 18 23 You can try and play with this plugin demonstration [clicking here](https://tastewp.com/new?pre-installed-plugin-slug=woocommerce%2Cwoocommerce-ajax-cart&redirect=plugins.php&ni=true) … … 22 27 Free version features: 23 28 24 * Automatically reload and recalculate Cart using AJAX when quantity changes29 * Automatically reload and recalculate the classic Cart using AJAX when quantity changes 25 30 * Show -/+ buttons around item quantity on cart page 26 31 * Show item quantity as select instead numeric field 27 * Show user confirmation when change item quantity to zero 32 * Show user confirmation when change item quantity to zero — and, on the Cart block, before an item is removed 33 * Side cart: a cart drawer that slides in when a product is added, with a floating cart button and item count 28 34 29 35 Premium version features: … … 34 40 * Option to lock quantity inputs to allow only change using plus and minus buttons 35 41 * Update price vs quantity calculation automatically on Single Product pages 42 * Change quantities with -/+ buttons inside the side cart 43 * Free shipping progress bar ("Spend $12.00 more for free shipping") in the side cart, Mini-Cart, classic Cart and Cart block — the amount read from your free shipping method, or your own 44 * Undo a removed item on the Cart block 45 * Minimum, maximum and step for every product quantity, on the classic and the block cart 36 46 37 47 If you looking for a related plugin with more complete features maybe you can try [Better Usability for WooCommerce](https://wordpress.org/plugins/woo-better-usability) plugin. … … 48 58 49 59 == Changelog == 60 61 = 1.4.0 = 62 * New: side cart — a cart drawer that slides in from the side when a product is added, with a floating cart button and item count (Settings > Side cart; off by default) 63 * New: on the Cart block, a confirmation before an item is removed (with the "confirmation when quantity goes to zero" setting) 64 * The description now says where each feature applies: the classic cart page, and what the Cart block already does by itself 65 * Changed: a cleaner settings page — the settings in a card, one row each with the label and its field aligned, on/off settings as switches, multiple choices as chips, a setting's sub-options in a panel under it, and Reset set apart from Save 50 66 51 67 = 1.3.28 = -
woocommerce-ajax-cart/trunk/wooajaxcart.php
r3757257 r3767494 4 4 Plugin URI: https://wordpress.org/plugins/woocommerce-ajax-cart/ 5 5 Description: Updates the WooCommerce cart with AJAX as soon as a quantity changes — no "Update cart" click needed 6 Version: 1. 3.286 Version: 1.4.0 7 7 Author: Moises Heberle 8 8 Author URI: https://mhtec.org/contact/ … … 28 28 add_filter('woocommerce_cart_item_quantity', 'wac_filter_woocommerce_cart_item_quantity', 10, 3); 29 29 add_filter('wc_get_template', 'wac_get_template', 10, 5 ); 30 add_action('wp_footer', 'wac_side_cart_render'); 31 add_filter('woocommerce_add_to_cart_fragments', 'wac_side_cart_fragments'); 30 32 31 33 add_action( 'before_woocommerce_init', function() { … … 82 84 'default' => 'no', 83 85 ); 86 $arr['side_cart'] = array( 87 'label' => __('Enable the side cart: a cart drawer that slides in from the side, on every page but the cart and checkout', 'woocommerce-ajax-cart'), 88 'tab' => __('Side cart', 'woocommerce-ajax-cart'), 89 'type' => 'checkbox', 90 'default' => 'no', 91 ); 92 $arr['side_cart_open_on_add'] = array( 93 'label' => __('Open the side cart when a product is added to the cart', 'woocommerce-ajax-cart'), 94 'tab' => __('Side cart', 'woocommerce-ajax-cart'), 95 'type' => 'checkbox', 96 'default' => 'yes', 97 'depends_on' => 'side_cart', 98 ); 99 $arr['side_cart_button'] = array( 100 'label' => __('Show a floating cart button with the item count', 'woocommerce-ajax-cart'), 101 'tab' => __('Side cart', 'woocommerce-ajax-cart'), 102 'type' => 'checkbox', 103 'default' => 'yes', 104 'depends_on' => 'side_cart', 105 ); 84 106 $arr['ajax_timeout'] = array( 85 107 'label' => __('AJAX timeout in milliseconds to refresh the cart on change', 'woocommerce-ajax-cart'), … … 121 143 $frontendData = wac_frontend_vars(); 122 144 wp_localize_script( 'wooajaxcart', 'wooajaxcart', $frontendData ); 145 146 if ( wac_side_cart_enabled() ) { 147 // The drawer holds the Mini-Cart, which WooCommerce refreshes through its cart fragments. 148 wp_enqueue_script('wc-cart-fragments'); 149 wp_enqueue_style('wac-side-cart', plugins_url('assets/wac-side-cart.css', plugin_basename(WAC_BASE_FILE)), array(), (string) filemtime($dir . 'assets/wac-side-cart.css')); 150 wp_enqueue_script('wac-side-cart', plugins_url('assets/wac-side-cart.js', plugin_basename(WAC_BASE_FILE)), array('jquery'), (string) filemtime($dir . 'assets/wac-side-cart.js'), true); 151 wp_localize_script('wac-side-cart', 'wac_side_cart', array( 152 'open_on_add' => wac_option('side_cart_open_on_add'), 153 )); 154 } 155 156 // The Cart block updates quantities by itself; what it lacks is a confirmation before an item is removed. 157 if ( is_cart() && wac_option('confirmation_zero_qty') == 'yes' && has_block('woocommerce/cart') ) { 158 wp_enqueue_script('wac-cart-block', plugins_url('assets/wac-cart-block.js', plugin_basename(WAC_BASE_FILE)), array(), (string) filemtime($dir . 'assets/wac-cart-block.js'), true); 159 wp_localize_script('wac-cart-block', 'wac_cart_block', array( 160 'warn_remove_text' => __( 'Are you sure you want to remove this item from cart?', 'woocommerce-ajax-cart' ), 161 )); 162 } 163 } 164 165 function wac_side_cart_enabled() { 166 return ( wac_option('side_cart') == 'yes' ) && function_exists('WC') && ! is_cart() && ! is_checkout(); 167 } 168 169 function wac_side_cart_count() { 170 return ( function_exists('WC') && WC()->cart ) ? (int) WC()->cart->get_cart_contents_count() : 0; 171 } 172 173 // The drawer: WooCommerce's own Mini-Cart (refreshed by its cart fragments) in a panel that slides in. 174 function wac_side_cart_render() { 175 if ( ! wac_side_cart_enabled() ) { 176 return; 177 } 178 179 if ( wac_option('side_cart_button') == 'yes' ) { 180 echo '<button type="button" class="wac-side-cart-toggle" aria-controls="wac-side-cart" aria-expanded="false" aria-label="' . esc_attr__( 'Open the cart', 'woocommerce-ajax-cart' ) . '">'; 181 echo '<svg class="wac-side-cart-icon" viewBox="0 0 24 24" width="26" height="26" aria-hidden="true" focusable="false"><path fill="currentColor" d="M7 18a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm10 0a2 2 0 1 0 0 4 2 2 0 0 0 0-4zM7.2 14h9.9c.8 0 1.4-.4 1.7-1.1l3.1-6.4L20.1 5.6 17.2 12H8.1L4.3 4H1v2h2l3.6 7.6-1.4 2.4C4.5 17.3 5.5 19 7 19h12v-2H7l1.1-2z"/></svg>'; 182 echo '<span class="wac-side-cart-count">' . esc_html( wac_side_cart_count() ) . '</span>'; 183 echo '</button>'; 184 } 185 186 echo '<div class="wac-side-cart-overlay" hidden></div>'; 187 echo '<aside id="wac-side-cart" class="wac-side-cart" aria-hidden="true" aria-label="' . esc_attr__( 'Cart', 'woocommerce-ajax-cart' ) . '">'; 188 echo '<div class="wac-side-cart-header">'; 189 echo '<span class="wac-side-cart-title">' . esc_html__( 'Your cart', 'woocommerce-ajax-cart' ) . '</span>'; 190 echo '<button type="button" class="wac-side-cart-close" aria-label="' . esc_attr__( 'Close the cart', 'woocommerce-ajax-cart' ) . '">×</button>'; 191 echo '</div>'; 192 do_action('wac_side_cart_before_items'); 193 echo '<div class="widget_shopping_cart wac-side-cart-body"><div class="widget_shopping_cart_content">'; 194 woocommerce_mini_cart(); 195 echo '</div></div>'; 196 do_action('wac_side_cart_after_items'); 197 echo '</aside>'; 198 } 199 200 function wac_side_cart_fragments( $fragments ) { 201 $fragments['span.wac-side-cart-count'] = '<span class="wac-side-cart-count">' . esc_html( wac_side_cart_count() ) . '</span>'; 202 203 return $fragments; 123 204 } 124 205
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)