Changeset 2499665
- Timestamp:
- 03/19/2021 07:45:12 PM (5 years ago)
- Location:
- enhanced-ajax-add-to-cart-for-woocommerce
- Files:
-
- 86 added
- 5 edited
-
tags/2.2.0 (added)
-
tags/2.2.0/LICENSE.txt (added)
-
tags/2.2.0/README.txt (added)
-
tags/2.2.0/assets (added)
-
tags/2.2.0/assets/css (added)
-
tags/2.2.0/assets/css/enhanced-ajax-add-to-cart-wc-public.css (added)
-
tags/2.2.0/assets/js (added)
-
tags/2.2.0/assets/js/enhanced-ajax-add-to-cart-wc-public.js (added)
-
tags/2.2.0/blocks (added)
-
tags/2.2.0/blocks/a2cp (added)
-
tags/2.2.0/blocks/a2cp/block.js (added)
-
tags/2.2.0/blocks/a2cp/editor.css (added)
-
tags/2.2.0/blocks/a2cp/index.js (added)
-
tags/2.2.0/blocks/a2cp/style.css (added)
-
tags/2.2.0/blocks/common (added)
-
tags/2.2.0/blocks/common/a2c-control.js (added)
-
tags/2.2.0/blocks/common/api (added)
-
tags/2.2.0/blocks/common/api/index.js (added)
-
tags/2.2.0/blocks/common/api/request.js (added)
-
tags/2.2.0/blocks/common/assets (added)
-
tags/2.2.0/blocks/common/assets/css (added)
-
tags/2.2.0/blocks/common/assets/css/style.css (added)
-
tags/2.2.0/blocks/common/formatting (added)
-
tags/2.2.0/blocks/common/formatting/errors.js (added)
-
tags/2.2.0/blocks/common/formatting/html.js (added)
-
tags/2.2.0/blocks/common/formatting/price.js (added)
-
tags/2.2.0/blocks/common/formatting/title.js (added)
-
tags/2.2.0/blocks/common/hierarchy.js (added)
-
tags/2.2.0/blocks/common/icons (added)
-
tags/2.2.0/blocks/common/icons/back.js (added)
-
tags/2.2.0/blocks/common/icons/checkbox-checked.js (added)
-
tags/2.2.0/blocks/common/icons/checkbox-unchecked.js (added)
-
tags/2.2.0/blocks/common/icons/index.js (added)
-
tags/2.2.0/blocks/common/icons/radio-selected.js (added)
-
tags/2.2.0/blocks/common/icons/radio-unselected.js (added)
-
tags/2.2.0/blocks/common/product-control (added)
-
tags/2.2.0/blocks/common/product-control/index.js (added)
-
tags/2.2.0/blocks/common/product-control/search-list-control.js (added)
-
tags/2.2.0/blocks/common/product-control/search-list-item.js (added)
-
tags/2.2.0/blocks/common/product-control/state (added)
-
tags/2.2.0/blocks/common/product-control/state/actions.js (added)
-
tags/2.2.0/blocks/common/product-control/state/actions.test.js (added)
-
tags/2.2.0/blocks/common/product-control/state/reducer.js (added)
-
tags/2.2.0/blocks/common/product-control/state/reducer.test.js (added)
-
tags/2.2.0/blocks/common/product-control/view.js (added)
-
tags/2.2.0/blocks/common/search-control.js (added)
-
tags/2.2.0/blocks/common/search-product-util.js (added)
-
tags/2.2.0/blocks/common/search-product-variation-util.js (added)
-
tags/2.2.0/blocks/common/search-variation-control.js (added)
-
tags/2.2.0/blocks/common/tag.js (added)
-
tags/2.2.0/blocks/common/utils (added)
-
tags/2.2.0/blocks/common/utils/local-api-middleware.js (added)
-
tags/2.2.0/blocks/common/utils/local-storage-polyfill.js (added)
-
tags/2.2.0/blocks/common/utils/local-storage.js (added)
-
tags/2.2.0/blocks/common/utils/parse-json.js (added)
-
tags/2.2.0/dist (added)
-
tags/2.2.0/dist/blocks (added)
-
tags/2.2.0/dist/blocks/a2cp.asset.php (added)
-
tags/2.2.0/dist/blocks/a2cp.js (added)
-
tags/2.2.0/dist/request (added)
-
tags/2.2.0/dist/request/a2c-submit.asset.php (added)
-
tags/2.2.0/dist/request/a2c-submit.js (added)
-
tags/2.2.0/enhanced-ajax-add-to-cart-wc.php (added)
-
tags/2.2.0/index.php (added)
-
tags/2.2.0/languages (added)
-
tags/2.2.0/languages/enhanced-ajax-add-to-cart-wc.po (added)
-
tags/2.2.0/languages/enhanced-ajax-add-to-cart-wc.pot (added)
-
tags/2.2.0/src (added)
-
tags/2.2.0/src/abstract-eaa2c-button.php (added)
-
tags/2.2.0/src/class-eaa2c-activator.php (added)
-
tags/2.2.0/src/class-eaa2c-admin.php (added)
-
tags/2.2.0/src/class-eaa2c-ajax.php (added)
-
tags/2.2.0/src/class-eaa2c-deactivator.php (added)
-
tags/2.2.0/src/class-eaa2c-i18n.php (added)
-
tags/2.2.0/src/class-eaa2c-loader.php (added)
-
tags/2.2.0/src/class-eaa2c-public.php (added)
-
tags/2.2.0/src/class-eaa2c-settings.php (added)
-
tags/2.2.0/src/class-eaa2c-single.php (added)
-
tags/2.2.0/src/class-enhanced-ajax-add-to-cart-wc.php (added)
-
tags/2.2.0/src/index.php (added)
-
tags/2.2.0/src/legacy (added)
-
tags/2.2.0/src/legacy/shortcode.php (added)
-
tags/2.2.0/uninstall.php (added)
-
tags/2.2.0/woo-includes (added)
-
tags/2.2.0/woo-includes/class-eaa2cwc-dependencies.php (added)
-
tags/2.2.0/woo-includes/woo-functions.php (added)
-
trunk/README.txt (modified) (5 diffs)
-
trunk/enhanced-ajax-add-to-cart-wc.php (modified) (2 diffs)
-
trunk/src/abstract-eaa2c-button.php (modified) (1 diff)
-
trunk/src/class-eaa2c-admin.php (modified) (1 diff)
-
trunk/src/class-eaa2c-single.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
enhanced-ajax-add-to-cart-for-woocommerce/trunk/README.txt
r2482400 r2499665 4 4 Tags: ajax button, add to cart, AJAX add to cart, shortcode, block, woocommerce 5 5 Requires at least: 4.8.1 6 Tested up to: 5. 66 Tested up to: 5.7 7 7 Requires PHP: 5.6 8 8 Stable tag: trunk … … 18 18 19 19 **Find the newly released Pro version [here](https://www.addtocartpro.com)!** 20 **Premium now has a GROUP shortcode!** 21 `[a2c_group_buttons 22 product={1,2,3,4...} 23 order={"title,quantity,separator,price,description"} // any order you want, also accepts first letters as arguments "q,s,t,p,d" for example. 24 class={STRING} 25 button_text={STRING} 26 title={none|attribute} 27 quantity={INTEGER}... 28 /]` 20 29 21 30 **Breaking Changes in 2.0 found [here](https://www.theritesites.com/docs/breaking-changes-upgrading-from-1-x-to-2-x/)** … … 64 73 - show_price 65 74 - button_text 66 67 `[enh_ajax_add_to_cart_button product={pid} variation={vid} show_price={beginning|b|after|a|rear|r} button_text={STRING} title={none|attributes|att|attribute} quantity={INTEGER} show_quantity={yes} ] 68 [ajax_add_to_cart product={pid} variation={vid} show_price={beginning|b|after|a|rear|r} button_text={STRING} title={none|attributes|att|attribute} quantity={INTEGER} show_quantity={yes} ] 69 [a2c_button product={pid} variation={vid} show_price={beginning|b|after|a|rear|r} button_text={STRING} title={none|attributes|att|attribute} quantity={INTEGER} show_quantity={yes} ]` 70 75 - class 76 - order (overrides show_quantity, show_price) 77 78 Original single button shortcode: 79 `[a2c_button 80 product={pid} 81 variation={vid} 82 class={STRING} 83 order={"title,quantity,separator,price,description"} // any order you want, also accepts first letters as arguments "q,s,t,p,d" for example. 84 show_price={beginning|b|after|a|rear|r} 85 button_text={STRING} 86 title={none|attributes|att|attribute} 87 quantity={INTEGER} 88 show_quantity={yes} 89 /]` 90 91 Documentation notes: 92 - The curly brackets "\{ \}" denote a list of options separated by a pipe " | " 93 - With the exception of "pid" and "vid" options, the lower case "options" within the curly braces are to represent different settings available for the front end display order. These will soon be deprecated for a new property "order" 94 - "pid" represents a product id, INTEGER value. 95 - "vid" represents a variation id, INTEGER value. 96 - STRING and INTEGER are to represent types. 97 - INTEGER expects a whole number, and decimals are not fully supported yet. 98 - STRING can have spaces in it if enclosed in quotes ("This is a string.") otherwise it will take 1 word. 99 100 Legacy shortcodes will remain working and will always take the options above: 101 102 `[enh_ajax_add_to_cart_button product={pid} variation={vid} /] 103 [ajax_add_to_cart product={pid} variation={vid} /]` 71 104 72 105 SIMPLE PRODUCT: Use only the required parameters to make a quantity box and add to cart button for a simple product with the title to the left: … … 155 188 156 189 Currently, we rely on themes to display a loading icon on the loading class. WooCommerce also provides one. 157 For more custom builds, we have on our near future enhancement list, a way to load spinner styles, or put your own in.158 For now, you can follow a guide to add a css class definition for "loading" in your themes style.css or customizers additional css.190 Our premium version now loads 2 spinners you can choose from using additional css classes and a setting. 191 The free version will be getting access to those spinners in version 2.3 or later. 159 192 160 193 … … 205 238 206 239 == Changelog == 240 241 = 2.2.0 = 242 * Added: New "order" prop on shortcode to determine display order and visibility of elements in a "button row" 243 * Added: New "class" prop on shortcode to add custom css classes to the "button row" 207 244 208 245 = 2.1.5 = -
enhanced-ajax-add-to-cart-for-woocommerce/trunk/enhanced-ajax-add-to-cart-wc.php
r2482400 r2499665 12 12 * Plugin URI: https://www.theritesites.com/plugins/enhanced-ajax-add-to-cart-wc 13 13 * Description: Creates a shortcode or block for you to be able to add an AJAX button with an associated quantity for you WooCommerce Product 14 * Version: 2. 1.514 * Version: 2.2.0 15 15 * Author: TheRiteSites 16 16 * Author URI: https://www.theritesites.com … … 35 35 * Current plugin version. 36 36 */ 37 defined( 'ENHANCED_AJAX_ADD_TO_CART' ) || define( 'ENHANCED_AJAX_ADD_TO_CART', '2. 1.5' );37 defined( 'ENHANCED_AJAX_ADD_TO_CART' ) || define( 'ENHANCED_AJAX_ADD_TO_CART', '2.2.0' ); 38 38 defined( 'EAA2C_PLUGIN_FILE' ) || define( 'EAA2C_PLUGIN_FILE', __FILE__ ); 39 39 -
enhanced-ajax-add-to-cart-for-woocommerce/trunk/src/abstract-eaa2c-button.php
r2482400 r2499665 421 421 } 422 422 423 // Is this actually being used correctly or did we regress further than expected? 424 // TODO: make more generic 425 protected function create_content_order_from_shortcode( $args ) { 426 427 $contentOrder = array(); 428 $args = strtolower( $args ); 429 if ( strpos( $args, 'b' ) !== false ) { 430 $contentOrder = array( 431 'price', 432 'separator', 433 'title', 434 'quantity', 435 'button', 436 ); 437 } 438 elseif ( strpos( $args, 'a' ) !== false ) { 439 $contentOrder = array( 440 'title', 441 'separator', 442 'price', 443 'quantity', 444 'button', 445 ); 446 } 447 elseif ( strpos( $args, 'r' ) !== false ) { 448 $contentOrder = array( 449 'title', 450 'quantity', 451 'button', 452 'separator', 453 'price', 454 ); 455 } 456 457 return $contentOrder; 458 } 459 460 protected function set_visibility( $element, $visibility = true ) { 461 $this->meta['contentVisibility'][$element] = $visibility; 462 } 463 464 protected function set_none_visible() { 465 foreach ( $this->meta['contentVisibility'] as $element => $visibility ) { 466 $this->meta['contentVisibility'][$element] = false; 467 } 468 } 469 470 protected function set_content_order( $contentOrder ) { 471 $this->meta['contentOrder'] = $contentOrder; 472 } 473 474 /** 475 * 476 * 'title', 477 * 'separator', 478 * 'price', 479 * 'quantity', 480 * 'button', 481 * 'custom', 482 * 'image', 483 * 'short_description' 484 */ 485 protected function create_block_display_from_order( $order_string ) { 486 $contentOrder = array(); 487 $this->set_none_visible(); 488 $args_long = strtolower( $order_string ); 489 $args = explode( ',', $args_long ); 490 foreach ( $args as $element ) { 491 if ( strpos( $element, 't' ) !== false ) { 492 $contentOrder[] = 'title'; 493 $this->set_visibility( 'title', true ); 494 } 495 if ( strpos( $element, 's' ) !== false ) { 496 $contentOrder[] = 'separator'; 497 $this->set_visibility( 'separator', true ); 498 } 499 if ( strpos( $element, 'p' ) !== false ) { 500 $contentOrder[] = 'price'; 501 $this->set_visibility( 'price', true ); 502 } 503 if ( strpos( $element, 'q' ) !== false ) { 504 $contentOrder[] = 'quantity'; 505 $this->set_visibility( 'quantity', true ); 506 } 507 if ( strpos( $element, 'b' ) !== false ) { 508 $contentOrder[] = 'button'; 509 $this->set_visibility( 'button', true ); 510 } 511 } 512 $this->set_content_order( $contentOrder ); 513 514 $returnData = array( 'contentOrder' => $this->meta['contentOrder'], 'contentVisibility' => $this->meta['contentVisibility'] ); 515 return $returnData; 516 } 517 423 518 } 424 519 } -
enhanced-ajax-add-to-cart-for-woocommerce/trunk/src/class-eaa2c-admin.php
r2482400 r2499665 77 77 'show_price' => '', // Added in version 1.3.0 78 78 'button_text' => '', // Added in version 1.3.0 79 'class' => '' // Added in version 2.0.0 79 'class' => '', // Added in version 2.0.0 80 'order' => '', // Added in version 2.2.0 80 81 ), $atts); 81 82 -
enhanced-ajax-add-to-cart-for-woocommerce/trunk/src/class-eaa2c-single.php
r2462572 r2499665 102 102 } 103 103 } 104 if ( isset( $attributes['show_price'] ) ) {104 if ( isset( $attributes['show_price'] ) && ( ! isset( $attributes['order'] ) || empty( $attributes['order'] ) ) ) { 105 105 // error_log( $attributes['show_price'] ); 106 106 $newContentOrder = $this->create_content_order_from_shortcode( $attributes['show_price'] ); … … 130 130 } 131 131 132 if ( isset( $attributes['order'] ) ) { 133 if ( ! empty( $order = sanitize_text_field( $attributes['order'] ) ) ) { 134 $returnedContent = $this->create_block_display_from_order( $attributes['order'] ); 135 $defaults['contentOrder'] = $returnedContent['contentOrder']; 136 $defaults['contentVisibility'] = $returnedContent['contentVisibility']; 137 // this should overwrite all others visibility. This makes show_prioe and show_quantity be ignored. 138 } 139 } 132 140 // error_log( wc_print_r( $defaults, true ) ); 133 141 … … 136 144 return $defaults; 137 145 } 138 139 private function create_content_order_from_shortcode( $args ) {140 141 $contentOrder = array();142 $args = strtolower( $args );143 if ( strpos( $args, 'b' ) !== false ) {144 $contentOrder = array(145 'price',146 'separator',147 'title',148 'quantity',149 'button',150 );151 }152 elseif ( strpos( $args, 'a' ) !== false ) {153 $contentOrder = array(154 'title',155 'separator',156 'price',157 'quantity',158 'button',159 );160 }161 elseif ( strpos( $args, 'r' ) !== false ) {162 $contentOrder = array(163 'title',164 'quantity',165 'button',166 'separator',167 'price',168 );169 }170 return $contentOrder;171 // strcmp( $att_array['show_price'], 'b' ) !== false === contentOrder[0] = 'price'172 // contentOrder[1] = 'separator'173 // contentOrder[2] = 'title'174 // contentOrder[3] = 'quantity'175 // contentOrder[4] = 'button'176 //177 // strcmp( $att_array['show_price'], 'a' ) !== false === contentOrder[0] = 'title'178 // contentOrder[1] = 'separator'179 // contentOrder[2] = 'price'180 // contentOrder[3] = 'quantity'181 // contentOrder[4] = 'button'182 //183 // strcmp( $att_array['show_price'], 'r' ) !== false === contentOrder[0] = 'title'184 // contentOrder[1] = 'quantity'185 // contentOrder[2] = 'button'186 // contentOrder[3] = 'separator'187 // contentOrder[4] = 'price'188 189 }190 146 } 191 147 }
Note: See TracChangeset
for help on using the changeset viewer.