Plugin Directory

Changeset 2499665


Ignore:
Timestamp:
03/19/2021 07:45:12 PM (5 years ago)
Author:
theritesites
Message:

2.2.0 - class & order and wp 5.7

Location:
enhanced-ajax-add-to-cart-for-woocommerce
Files:
86 added
5 edited

Legend:

Unmodified
Added
Removed
  • enhanced-ajax-add-to-cart-for-woocommerce/trunk/README.txt

    r2482400 r2499665  
    44Tags: ajax button, add to cart, AJAX add to cart, shortcode, block, woocommerce
    55Requires at least: 4.8.1
    6 Tested up to:      5.6
     6Tested up to:      5.7
    77Requires PHP:      5.6
    88Stable tag:        trunk
     
    1818
    1919**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/]`
    2029
    2130**Breaking Changes in 2.0 found [here](https://www.theritesites.com/docs/breaking-changes-upgrading-from-1-x-to-2-x/)**
     
    6473- show_price
    6574- 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
     78Original 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
     91Documentation 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
     100Legacy 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} /]`
    71104
    72105SIMPLE 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:
     
    155188
    156189Currently, 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.
     190Our premium version now loads 2 spinners you can choose from using additional css classes and a setting.
     191The free version will be getting access to those spinners in version 2.3 or later.
    159192
    160193
     
    205238
    206239== 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"
    207244
    208245= 2.1.5 =
  • enhanced-ajax-add-to-cart-for-woocommerce/trunk/enhanced-ajax-add-to-cart-wc.php

    r2482400 r2499665  
    1212 * Plugin URI:        https://www.theritesites.com/plugins/enhanced-ajax-add-to-cart-wc
    1313 * 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.5
     14 * Version:           2.2.0
    1515 * Author:            TheRiteSites
    1616 * Author URI:        https://www.theritesites.com
     
    3535 * Current plugin version.
    3636 */
    37 defined( 'ENHANCED_AJAX_ADD_TO_CART' ) || define( 'ENHANCED_AJAX_ADD_TO_CART', '2.1.5' );
     37defined( 'ENHANCED_AJAX_ADD_TO_CART' ) || define( 'ENHANCED_AJAX_ADD_TO_CART', '2.2.0' );
    3838defined( 'EAA2C_PLUGIN_FILE' ) || define( 'EAA2C_PLUGIN_FILE', __FILE__ );
    3939
  • enhanced-ajax-add-to-cart-for-woocommerce/trunk/src/abstract-eaa2c-button.php

    r2482400 r2499665  
    421421        }
    422422
     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
    423518    }
    424519}
  • enhanced-ajax-add-to-cart-for-woocommerce/trunk/src/class-eaa2c-admin.php

    r2482400 r2499665  
    7777                'show_price'    => '', // Added in version 1.3.0
    7878                '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
    8081            ), $atts);
    8182
  • enhanced-ajax-add-to-cart-for-woocommerce/trunk/src/class-eaa2c-single.php

    r2462572 r2499665  
    102102                }
    103103            }
    104             if ( isset( $attributes['show_price'] ) ) {
     104            if ( isset( $attributes['show_price'] ) && ( ! isset( $attributes['order'] ) || empty( $attributes['order'] ) ) ) {
    105105                // error_log( $attributes['show_price'] );
    106106                $newContentOrder = $this->create_content_order_from_shortcode( $attributes['show_price'] );
     
    130130            }
    131131
     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            }
    132140            // error_log( wc_print_r( $defaults, true ) );
    133141
     
    136144            return $defaults;
    137145        }
    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         }
    190146    }
    191147}
Note: See TracChangeset for help on using the changeset viewer.