WordPress.org

Plugin Directory

Changeset 1647397


Ignore:
Timestamp:
04/28/17 12:32:53 (5 months ago)
Author:
sormano
Message:

Versioning WAFS 1.1.1

Location:
woocommerce-advanced-free-shipping
Files:
34 added
6 deleted
38 edited
19 copied

Legend:

Unmodified
Added
Removed
  • woocommerce-advanced-free-shipping/tags/1.1.1/includes/admin/class-wafs-admin.php

    r1609491 r1647397  
    5555    public function admin_enqueue_scripts() { 
    5656 
    57         $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; 
    58  
    5957        wp_register_style( 'woocommerce-advanced-free-shipping', plugins_url( 'assets/css/woocommerce-advanced-free-shipping.min.css', WAFS()->file ), array(), WAFS()->version ); 
    60         wp_register_script( 'woocommerce-advanced-free-shipping', plugins_url( 'assets/js/woocommerce-advanced-free-shipping' . $suffix . '.js', WAFS()->file ), array( 'jquery' ), WAFS()->version, true ); 
    61         wp_localize_script( 'woocommerce-advanced-free-shipping', 'wafs', array( 
    62             'nonce' => wp_create_nonce( 'wpc-ajax-nonce' ), 
    63         ) ); 
    6458 
    6559        if ( 
     
    7468 
    7569            wp_enqueue_style( 'woocommerce-advanced-free-shipping' ); 
    76             wp_enqueue_script( 'woocommerce-advanced-free-shipping' ); 
    7770            wp_enqueue_script( 'wp-conditions' ); 
    7871 
  • woocommerce-advanced-free-shipping/tags/1.1.1/includes/core-functions.php

    r1609491 r1647397  
    7979 
    8080} 
    81 add_action( 'wp-conditions\html_field_hook', 'wafs_add_bc_action_custom_fields' ); 
     81add_action( 'wp-conditions\html_field_hook', 'wafs_add_bc_action_custom_fields', 10, 2 ); 
  • woocommerce-advanced-free-shipping/tags/1.1.1/libraries/wp-conditions/assets/js/wp-conditions.js

    r1609491 r1647397  
    3232    // Assign new ID to repeater row + open collapsible + re-enable nested repeater 
    3333    jQuery( document.body ).on( 'repeater-added-row', function( e, template, container, $self ) { 
    34         var new_id = Math.floor(Math.random()*8999999999+1000000000); // Random number sequence of 10 length 
     34        var new_id = Math.floor(Math.random()*899999999+100000000); // Random number sequence of 9 length 
    3535        template.find( 'input[name], select[name]' ).attr( 'name', function( index, value ) { 
    3636            return ( value.replace( '9999', new_id ) ) || value; 
     
    5656            condition_group_list = $( this ).parents( '.wpc-conditions' ), 
    5757            new_group            = condition_group_wrap.clone(), 
    58             new_group_id         = Math.floor(Math.random()*8999999999+1000000000); // Random number sequence of 10 length 
     58            new_group_id         = Math.floor(Math.random()*899999999+100000000); // Random number sequence of 9 length 
    5959 
    6060        // Fix dropdown selected not being cloned properly 
  • woocommerce-advanced-free-shipping/tags/1.1.1/libraries/wp-conditions/assets/js/wp-conditions.min.js

    r1609491 r1647397  
    1 jQuery(function($){function t(){$(".wpc-conditions").parents(".postbox").repeater({addTrigger:".wpc-condition-group-add",removeTrigger:".wpc-condition-group .delete",template:".wpc-condition-group-template .wpc-condition-group-wrap",elementWrap:".wpc-condition-group-wrap",elementsContainer:".wpc-conditions",removeElement:function(t){t.remove()}})}function o(){$(".wpc-condition-group").repeater({addTrigger:".wpc-condition-add",removeTrigger:".wpc-condition-delete",template:".wpc-condition-template .wpc-condition-wrap",elementWrap:".wpc-condition-wrap",elementsContainer:".wpc-conditions-list"})}t(),o(),jQuery(document.body).on("repeater-added-row",function(t,e,n,i){var a=Math.floor(8999999999*Math.random()+1e9);e.find("input[name], select[name]").attr("name",function(t,o){return o.replace("9999",a)||o}),e.find(".wpc-condition[data-id]").attr("data-id",function(t,o){return o.replace("9999",a)||o}),e.find("[data-group]").attr("data-group",function(t,o){return o.replace("9999",a)||o}),e.find(".repeater-active").removeClass("repeater-active"),o()}),$(document.body).on("click",".wpc-conditions .duplicate",function(){var t=$(this).parents(".wpc-condition-group-wrap"),e=t.find(".wpc-condition-group").attr("data-group"),n=$(this).parents(".wpc-conditions"),i=t.clone(),a=Math.floor(8999999999*Math.random()+1e9);$(t).find("select").each(function(t){$(i).find("select").eq(t).val($(this).val())}),i.find(".wpc-condition-group").attr("data-group",a),i.find("input[name], select[name]").attr("name",function(t,o){return o.replace("conditions["+e+"]","conditions["+a+"]")}),i.find(".repeater-active").removeClass("repeater-active"),n.append(i),o(),$("html, body").on("scroll mousedown DOMMouseScroll mousewheel keydown touchmove",function(t){$("html, body").stop().off("scroll mousedown DOMMouseScroll mousewheel keydown touchmove")}),$("body, html").animate({scrollTop:$(i).offset().top-50},750,function(){$("html, body").off("scroll mousedown DOMMouseScroll mousewheel keydown touchmove")})}),$(document.body).on("change",".wpc-condition",function(){var t='<span style="width: calc( 42.5% - 75px ); border: 1px solid transparent; display: inline-block;">&nbsp;</span>',o={action:wpc2.action_prefix+"update_condition_value",id:$(this).attr("data-id"),group:$(this).parents(".wpc-condition-group").attr("data-group"),condition:$(this).val(),nonce:wpc.nonce},e=$(this).parents(".wpc-condition-wrap").first(),n=".wpc-value-field-wrap";e.find(n).html(t).block({message:null,overlayCSS:{background:"",opacity:.6}}),$.post(ajaxurl,o,function(t){e.find(n).replaceWith(t),$(document.body).trigger("wc-enhanced-select-init")});var i=e.find(".wpc-operator").val();e.find(".wpc-operator").empty().html(function(){var t=$(this),e=wpc.condition_operators[o.condition]||wpc.condition_operators["default"];$.each(e,function(o,e){t.append($("<option/>").attr("value",o).text(e)),t.val(i).val()||t.val(t.find("option:first").val())})}),e.find(".wpc-description").html(function(){return $('<span class="woocommerce-help-tip" />').attr("data-tip",wpc.condition_descriptions[o.condition]||"")}),$(".tips, .help_tip, .woocommerce-help-tip").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200}),$("#tiptip_holder").removeAttr("style"),$("#tiptip_arrow").removeAttr("style")}),$(".wpc-conditions-post-table.wpc-sortable-post-table tbody").sortable({items:"tr",handle:".sort",cursor:"move",axis:"y",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"wc-metabox-sortable-placeholder",start:function(t,o){o.item.css("background-color","#f6f6f6")},stop:function(t,o){o.item.removeAttr("style")},update:function(t,o){$table=$(this).closest("table"),$table.block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var e={action:"wpc_save_post_order",form:$(this).closest("form").serialize(),nonce:wpc.nonce};$.post(ajaxurl,e,function(t){$(".wpc-conditions-post-table tbody tr:even").addClass("alternate"),$(".wpc-conditions-post-table tbody tr:odd").removeClass("alternate"),$table.unblock()})}})}); 
     1jQuery(function($){function t(){$(".wpc-conditions").parents(".postbox").repeater({addTrigger:".wpc-condition-group-add",removeTrigger:".wpc-condition-group .delete",template:".wpc-condition-group-template .wpc-condition-group-wrap",elementWrap:".wpc-condition-group-wrap",elementsContainer:".wpc-conditions",removeElement:function(t){t.remove()}})}function o(){$(".wpc-condition-group").repeater({addTrigger:".wpc-condition-add",removeTrigger:".wpc-condition-delete",template:".wpc-condition-template .wpc-condition-wrap",elementWrap:".wpc-condition-wrap",elementsContainer:".wpc-conditions-list"})}t(),o(),jQuery(document.body).on("repeater-added-row",function(t,e,n,i){var a=Math.floor(899999999*Math.random()+1e8);e.find("input[name], select[name]").attr("name",function(t,o){return o.replace("9999",a)||o}),e.find(".wpc-condition[data-id]").attr("data-id",function(t,o){return o.replace("9999",a)||o}),e.find("[data-group]").attr("data-group",function(t,o){return o.replace("9999",a)||o}),e.find(".repeater-active").removeClass("repeater-active"),o()}),$(document.body).on("click",".wpc-conditions .duplicate",function(){var t=$(this).parents(".wpc-condition-group-wrap"),e=t.find(".wpc-condition-group").attr("data-group"),n=$(this).parents(".wpc-conditions"),i=t.clone(),a=Math.floor(899999999*Math.random()+1e8);$(t).find("select").each(function(t){$(i).find("select").eq(t).val($(this).val())}),i.find(".wpc-condition-group").attr("data-group",a),i.find("input[name], select[name]").attr("name",function(t,o){return o.replace("conditions["+e+"]","conditions["+a+"]")}),i.find(".repeater-active").removeClass("repeater-active"),n.append(i),o(),$("html, body").on("scroll mousedown DOMMouseScroll mousewheel keydown touchmove",function(t){$("html, body").stop().off("scroll mousedown DOMMouseScroll mousewheel keydown touchmove")}),$("body, html").animate({scrollTop:$(i).offset().top-50},750,function(){$("html, body").off("scroll mousedown DOMMouseScroll mousewheel keydown touchmove")})}),$(document.body).on("change",".wpc-condition",function(){var t='<span style="width: calc( 42.5% - 75px ); border: 1px solid transparent; display: inline-block;">&nbsp;</span>',o={action:wpc2.action_prefix+"update_condition_value",id:$(this).attr("data-id"),group:$(this).parents(".wpc-condition-group").attr("data-group"),condition:$(this).val(),nonce:wpc.nonce},e=$(this).parents(".wpc-condition-wrap").first(),n=".wpc-value-field-wrap";e.find(n).html(t).block({message:null,overlayCSS:{background:"",opacity:.6}}),$.post(ajaxurl,o,function(t){e.find(n).replaceWith(t),$(document.body).trigger("wc-enhanced-select-init")});var i=e.find(".wpc-operator").val();e.find(".wpc-operator").empty().html(function(){var t=$(this),e=wpc.condition_operators[o.condition]||wpc.condition_operators["default"];$.each(e,function(o,e){t.append($("<option/>").attr("value",o).text(e)),t.val(i).val()||t.val(t.find("option:first").val())})}),e.find(".wpc-description").html(function(){return $('<span class="woocommerce-help-tip" />').attr("data-tip",wpc.condition_descriptions[o.condition]||"")}),$(".tips, .help_tip, .woocommerce-help-tip").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200}),$("#tiptip_holder").removeAttr("style"),$("#tiptip_arrow").removeAttr("style")}),$(".wpc-conditions-post-table.wpc-sortable-post-table tbody").sortable({items:"tr",handle:".sort",cursor:"move",axis:"y",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"wc-metabox-sortable-placeholder",start:function(t,o){o.item.css("background-color","#f6f6f6")},stop:function(t,o){o.item.removeAttr("style")},update:function(t,o){$table=$(this).closest("table"),$table.block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var e={action:"wpc_save_post_order",form:$(this).closest("form").serialize(),nonce:wpc.nonce};$.post(ajaxurl,e,function(t){$(".wpc-conditions-post-table tbody tr:even").addClass("alternate"),$(".wpc-conditions-post-table tbody tr:odd").removeClass("alternate"),$table.unblock()})}})}); 
  • woocommerce-advanced-free-shipping/tags/1.1.1/libraries/wp-conditions/conditions/wpc-city-condition.php

    r1609491 r1647397  
    1515        } 
    1616 
    17         // @todo - Check if this can be cleaned up 
    1817        public function match( $match, $operator, $value ) { 
    1918 
     
    2221 
    2322            if ( '==' == $operator ) : 
    24  
    25                 if ( preg_match( '/\, ?/', $value ) ) : 
    26                     $match = ( in_array( $customer_city, preg_split( '/\, ?/', $value ) ) ); 
    27                 else : 
    28                     $match = ( $value == $customer_city ); 
    29                 endif; 
    30  
     23                $match = ( in_array( $customer_city, preg_split( '/\, ?/', $value ) ) ); 
    3124            elseif ( '!=' == $operator ) : 
    32  
    33                 if ( preg_match( '/\, ?/', $value ) ) : 
    34                     $match = ( ! in_array( $customer_city, preg_split( '/\, ?/', $value ) ) ); 
    35                 else : 
    36                     $match = ( $value == $customer_city ); 
    37                 endif; 
    38  
     25                $match = ( ! in_array( $customer_city, preg_split( '/\, ?/', $value ) ) ); 
    3926            endif; 
    4027 
  • woocommerce-advanced-free-shipping/tags/1.1.1/libraries/wp-conditions/conditions/wpc-condition.php

    r1609491 r1647397  
    9999        public function match( $match, $operator, $value ) { 
    100100 
     101            if ( ! $this->validate() ) { 
     102                return false; 
     103            } 
     104 
    101105            $value = $this->get_value( $value ); 
    102106            $compare_value = $this->get_compare_value(); 
     
    115119        } 
    116120 
     121        /** 
     122         * Validates before matching function. 
     123         * Can be used for example to verify the global $product exists. 
     124         */ 
     125        public function validate() { 
     126            return true; 
     127        } 
     128 
    117129        public function get_description() { 
    118130            return $this->description; 
  • woocommerce-advanced-free-shipping/tags/1.1.1/libraries/wp-conditions/conditions/wpc-contains-product-condition.php

    r1609491 r1647397  
    3232 
    3333            $product_ids = array(); 
    34             foreach ( WC()->cart->cart_contents as $product ) : 
    35                 $product_ids[] = $product['product_id']; 
    36                 if ( isset( $product['variation_id'] ) ) { 
    37                     $product_ids[] = $product['variation_id']; 
     34            foreach ( WC()->cart->get_cart() as $item ) : 
     35                $product_ids[] = $item['product_id']; 
     36                if ( isset( $item['variation_id'] ) ) { 
     37                    $product_ids[] = $item['variation_id']; 
    3838                } 
    3939            endforeach; 
  • woocommerce-advanced-free-shipping/tags/1.1.1/libraries/wp-conditions/conditions/wpc-coupon-condition.php

    r1609491 r1647397  
    6363            $coupons = array( 'percent' => array(), 'fixed' => array() ); 
    6464            foreach ( WC()->cart->get_coupons() as $coupon ) { 
    65                 $type               = str_replace( '_product', '', $coupon->discount_type ); 
    66                 $type               = str_replace( '_cart', '', $type ); 
    67                 $coupons[ $type ][] = $coupon->coupon_amount; 
     65                /** @var $coupon WC_Coupon */ 
     66                if ( version_compare( WC()->version, '2.7', '>=' ) ) { 
     67                    $type               = str_replace( '_product', '', $coupon->get_discount_type() ); 
     68                    $type               = str_replace( '_cart', '', $type ); 
     69                    $coupons[ $type ][] = $coupon->get_amount(); 
     70                } else { 
     71                    $type               = str_replace( '_product', '', $coupon->discount_type ); 
     72                    $type               = str_replace( '_cart', '', $type ); 
     73                    $coupons[ $type ][] = $coupon->coupon_amount; 
     74                } 
    6875            } 
    6976 
  • woocommerce-advanced-free-shipping/tags/1.1.1/libraries/wp-conditions/conditions/wpc-height-condition.php

    r1609491 r1647397  
    1010            $this->slug        = __( 'height', 'wpc-conditions' ); 
    1111            $this->group       = __( 'Product', 'wpc-conditions' ); 
    12             $this->description = __( 'Compared to highest product in cart', 'wpc-conditions' ); 
     12            $this->description = __( 'Compared to the highest product in cart', 'wpc-conditions' ); 
    1313 
    1414            parent::__construct(); 
     
    1818 
    1919            $height = array(); 
    20             foreach ( WC()->cart->get_cart() as $product ) : 
     20            foreach ( WC()->cart->get_cart() as $item ) : 
    2121 
    22                 if ( true == $product['data']->variation_has_height ) : 
    23                     $height[] = ( get_post_meta( $product['data']->variation_id, '_height', true ) ); 
    24                 else : 
    25                     $height[] = ( get_post_meta( $product['product_id'], '_height', true ) ); 
    26                 endif; 
     22                /** @var $product WC_Product */ 
     23                $product = $item['data']; 
     24                $height[] = $product->get_height(); 
    2725 
    2826            endforeach; 
  • woocommerce-advanced-free-shipping/tags/1.1.1/libraries/wp-conditions/conditions/wpc-length-condition.php

    r1609491 r1647397  
    1010            $this->slug        = __( 'length', 'wpc-conditions' ); 
    1111            $this->group       = __( 'Product', 'wpc-conditions' ); 
    12             $this->description = __( 'Compared to lengthiest product in cart', 'wpc-conditions' ); 
     12            $this->description = __( 'Compared to the lengthiest product in cart', 'wpc-conditions' ); 
    1313 
    1414            parent::__construct(); 
     
    1818 
    1919            $length = array(); 
    20             foreach ( WC()->cart->get_cart() as $product ) : 
     20            foreach ( WC()->cart->get_cart() as $item ) : 
    2121 
    22                 if ( true == $product['data']->variation_has_length ) : 
    23                     $length[] = ( get_post_meta( $product['data']->variation_id, '_length', true ) ); 
    24                 else : 
    25                     $length[] = ( get_post_meta( $product['product_id'], '_length', true ) ); 
    26                 endif; 
     22                /** @var $product WC_Product */ 
     23                $product = $item['data']; 
     24                $length[] = $product->get_length(); 
    2725 
    2826            endforeach; 
  • woocommerce-advanced-free-shipping/tags/1.1.1/libraries/wp-conditions/conditions/wpc-role-condition.php

    r1609491 r1647397  
    3131 
    3232        public function get_compare_value() { 
    33             global $current_user; 
    34             return $current_user->caps; 
     33            if ( is_user_logged_in() ) { 
     34                global $current_user; 
     35                return $current_user->caps; 
     36            } else { 
     37                return array( 'not_logged_in' ); 
     38            } 
     39 
    3540        } 
    3641 
     
    4954 
    5055            $user_roles = array_keys( get_editable_roles() ); 
     56            $user_roles = array_combine( $user_roles, $user_roles ); 
     57            $user_roles['not_logged_in'] = __( 'Guest user', 'wp-conditions' ); 
    5158 
    5259            $field_args = array( 
    5360                'type' => 'select', 
    5461                'class' => array( 'wpc-value' ), 
    55                 'options' => array_combine( $user_roles, $user_roles ), 
     62                'options' => $user_roles, 
    5663            ); 
    5764 
  • woocommerce-advanced-free-shipping/tags/1.1.1/libraries/wp-conditions/conditions/wpc-stock-condition.php

    r1609491 r1647397  
    2020 
    2121            // $package['contents'] 
    22             foreach ( WC()->cart->get_cart() as $product ) : 
     22            foreach ( WC()->cart->get_cart() as $item ) : 
    2323 
    24                 if ( true == $product['data']->variation_has_stock ) : 
    25                     $stock[] = ( get_post_meta( $product['data']->variation_id, '_stock', true ) ); 
    26                 else : 
    27                     $stock[] = ( get_post_meta( $product['product_id'], '_stock', true ) ); 
    28                 endif; 
     24                /** @var $product WC_Product */ 
     25                $product = $item['data']; 
     26                $stock[] = $product->get_stock_quantity(); 
    2927 
    3028            endforeach; 
  • woocommerce-advanced-free-shipping/tags/1.1.1/libraries/wp-conditions/conditions/wpc-stock-status-condition.php

    r1609491 r1647397  
    2323                $match = true; 
    2424                // $package['contents'] 
    25                 foreach ( WC()->cart->get_cart() as $product ) : 
     25                foreach ( WC()->cart->get_cart() as $item ) : 
    2626 
    27                     if ( true == $product['data']->variation_has_stock ) : 
    28                         $stock_status = ( get_post_meta( $product['data']->variation_id, '_stock_status', true ) ); 
    29                     else : 
    30                         $stock_status = ( get_post_meta( $product['product_id'], '_stock_status', true ) ); 
    31                     endif; 
     27                    /** @var $product WC_Product */ 
     28                    $product = $item['data']; 
     29 
     30                    if ( method_exists( $product, 'get_stock_status' ) ) { // WC 2.7 compatibility 
     31                        $stock_status = $product->get_stock_status(); 
     32                    } else { // Pre 2.7 
     33                        $stock_status = $product->stock_status; 
     34                    } 
    3235 
    3336                    if ( $stock_status != $value ) : 
    34                         $match = false; 
     37                        return false; 
    3538                    endif; 
    3639 
     
    4144                $match = true; 
    4245                // $package['contents'] 
    43                 foreach ( WC()->cart->get_cart() as $product ) : 
     46                foreach ( WC()->cart->get_cart() as $item ) : 
    4447 
    45                     if ( true == $product['data']->variation_has_stock ) : 
    46                         $stock_status = ( get_post_meta( $product['data']->variation_id, '_stock_status', true ) ); 
    47                     else : 
    48                         $stock_status = ( get_post_meta( $product['product_id'], '_stock_status', true ) ); 
    49                     endif; 
     48                    /** @var $product WC_Product */ 
     49                    $product = $item['data']; 
     50 
     51                    if ( method_exists( $product, 'get_stock_status' ) ) { // WC 2.7 compatibility 
     52                        $stock_status = $product->get_stock_status(); 
     53                    } else { // Pre 2.7 
     54                        $stock_status = $product->stock_status; 
     55                    } 
    5056 
    5157                    if ( $stock_status == $value ) : 
    52                         $match = false; 
     58                        return false; 
    5359                    endif; 
    5460 
     
    5662 
    5763            endif; 
     64 
     65            return $match; 
    5866 
    5967        } 
     
    7078        } 
    7179 
     80        public function get_value_field_args() { 
     81 
     82            $field_args = array( 
     83                'type'    => 'select', 
     84                'options' => array( 
     85                    '1' => __( 'In stock', 'woocommerce' ), 
     86                    '0' => __( 'Out of stock', 'woocommerce' ), 
     87                ), 
     88            ); 
     89 
     90            return $field_args; 
     91 
     92        } 
     93 
    7294    } 
    7395 
  • woocommerce-advanced-free-shipping/tags/1.1.1/libraries/wp-conditions/conditions/wpc-subtotal-condition.php

    r1609491 r1647397  
    1616 
    1717        public function get_value( $value ) { 
    18             // Make sure its formatted correct 
    1918            return str_replace( ',', '.', $value ); 
    2019        } 
  • woocommerce-advanced-free-shipping/tags/1.1.1/libraries/wp-conditions/conditions/wpc-time-condition.php

    r1609491 r1647397  
    2828                'type' => 'text', 
    2929                'class' => array( 'wpc-value' ), 
    30                 'placeholder' => 'dd-mm-yyyy or yyyy-mm-dd', 
     30                'placeholder' => sprintf( __( 'Current time is: %s', 'woocommerce-advanced-messages' ), current_time( 'H:i' ) ), 
    3131            ); 
    3232 
  • woocommerce-advanced-free-shipping/tags/1.1.1/libraries/wp-conditions/conditions/wpc-weight-condition.php

    r1609491 r1647397  
    1616 
    1717        public function get_value( $value ) { 
    18             // Make sure its formatted correct 
    1918            return str_replace( ',', '.', $value ); 
    2019        } 
  • woocommerce-advanced-free-shipping/tags/1.1.1/libraries/wp-conditions/conditions/wpc-width-condition.php

    r1609491 r1647397  
    1010            $this->slug        = __( 'width', 'wpc-conditions' ); 
    1111            $this->group       = __( 'Product', 'wpc-conditions' ); 
    12             $this->description = __( 'Compared to widest product in cart', 'wpc-conditions' ); 
     12            $this->description = __( 'Compared to the widest product in cart', 'wpc-conditions' ); 
    1313 
    1414            parent::__construct(); 
     
    1818 
    1919            $width = array(); 
    20             foreach ( WC()->cart->get_cart() as $product ) : 
     20            foreach ( WC()->cart->get_cart() as $item ) : 
    2121 
    22                 if ( true == $product['data']->variation_has_width ) : 
    23                     $width[] = ( get_post_meta( $product['data']->variation_id, '_width', true ) ); 
    24                 else : 
    25                     $width[] = ( get_post_meta( $product['product_id'], '_width', true ) ); 
    26                 endif; 
     22                /** @var $product WC_Product */ 
     23                $product = $item['data']; 
     24                $width[] = $product->get_width(); 
    2725 
    2826            endforeach; 
  • woocommerce-advanced-free-shipping/tags/1.1.1/libraries/wp-conditions/conditions/wpc-zipcode-condition.php

    r1609491 r1647397  
    1818 
    1919            $zipcode = $this->get_compare_value(); 
    20  
    21             // Prepare the store-owner set value 
    22             $value_zipcodes = array(); 
    23             if ( preg_match( '/\, ?/', $value ) ) : 
    24  
    25                 foreach ( preg_split( '/\, ?/', $value ) as $v ) : 
    26                     $value_zipcodes[] = preg_replace( '/[^0-9a-zA-Z\-]/', '', $v ); 
    27                 endforeach; 
    28  
    29             else : 
    30                 $value_zipcodes[] = preg_replace( '/[^0-9a-zA-Z\-]/', '', $value ); 
    31             endif; 
     20            $value_zipcodes = $this->get_value( $value ); 
    3221 
    3322            // Match zipcode 
     
    4433                $match = true; 
    4534                foreach ( $value_zipcodes as $zip ) : 
    46                     if ( $match = ! preg_match( '/^' . preg_quote( $zip, '/' ) . '/i', $zipcode ) ) : 
     35                    if ( preg_match( '/^' . preg_quote( $zip, '/' ) . '/i', $zipcode ) ) : 
     36                        return $match = false; 
    4737                        break; 
    4838                    endif; 
     
    7363        } 
    7464 
     65        public function get_value( $value ) { 
     66 
     67            $value_zipcodes = array(); 
     68            foreach ( preg_split( '/\, ?/', $value ) as $v ) : 
     69                $value_zipcodes[] = preg_replace( '/[^0-9a-zA-Z\-]/', '', $v ); 
     70            endforeach; 
     71 
     72            return $value_zipcodes; 
     73 
     74        } 
     75 
    7576        public function get_compare_value() { 
    7677            return preg_replace( '/[^0-9a-zA-Z\-]/', '', WC()->customer->get_shipping_postcode() ); 
  • woocommerce-advanced-free-shipping/tags/1.1.1/libraries/wp-conditions/functions.php

    r1609491 r1647397  
    3333require_once 'conditions/wpc-role-condition.php'; 
    3434 
     35// Product (cart based) 
    3536require_once 'conditions/wpc-length-condition.php'; 
    3637require_once 'conditions/wpc-width-condition.php'; 
     
    3940require_once 'conditions/wpc-stock-condition.php'; 
    4041require_once 'conditions/wpc-category-condition.php'; 
    41  
     42require_once 'conditions/wpc-volume-condition.php'; 
     43 
     44// Product (single based) 
     45require_once 'conditions/wpc-product-condition.php'; 
     46require_once 'conditions/wpc-product-age-condition.php'; 
     47require_once 'conditions/wpc-product-type-condition.php'; 
     48require_once 'conditions/wpc-product-category-condition.php'; 
     49require_once 'conditions/wpc-product-shipping-class-condition.php'; 
     50require_once 'conditions/wpc-product-tag-condition.php'; 
     51require_once 'conditions/wpc-product-height-condition.php'; 
     52require_once 'conditions/wpc-product-length-condition.php'; 
     53require_once 'conditions/wpc-product-price-condition.php'; 
     54require_once 'conditions/wpc-product-sale-price-condition.php'; 
     55require_once 'conditions/wpc-product-stock-condition.php'; 
     56require_once 'conditions/wpc-product-stock-status-condition.php'; 
     57require_once 'conditions/wpc-product-width-condition.php'; 
     58require_once 'conditions/wpc-product-sales-condition.php'; 
     59require_once 'conditions/wpc-product-on-sale-condition.php'; 
    4260 
    4361if ( ! function_exists( 'wpc_get_registered_conditions' ) ) { 
     
    7997            new WPC_Stock_Condition(), 
    8098            new WPC_Category_Condition(), 
     99            new WPC_Volume_Condition(), 
     100 
     101            new WPC_Product_Condition(), 
     102            new WPC_Product_Age_Condition(), 
     103            new WPC_Product_Type_Condition(), 
     104            new WPC_Product_Length_Condition(), 
     105            new WPC_Product_Width_Condition(), 
     106            new WPC_Product_Height_Condition(), 
     107            new WPC_Product_Stock_Status_Condition(), 
     108            new WPC_Product_Stock_Condition(), 
     109            new WPC_Product_Category_Condition(), 
     110            new WPC_Product_Shipping_Class_Condition(), 
     111            new WPC_Product_Tag_Condition(), 
     112            new WPC_Product_Price_Condition(), 
     113            new WPC_Product_Sale_Price_Condition(), 
     114            new WPC_Product_Sales_Condition(), 
     115            new WPC_Product_On_Sale_Condition(), 
    81116        ); 
    82117 
     
    103138 
    104139        $class_name = 'WPC_' . implode( '_', array_map( 'ucfirst', explode( '_', $condition ) ) ) . '_Condition'; 
     140        $class_name = apply_filters( 'wpc_get_condition_class_name', $class_name, $condition ); 
     141 
    105142        if ( class_exists( $class_name ) ) { 
    106143            return new $class_name(); 
  • woocommerce-advanced-free-shipping/tags/1.1.1/readme.txt

    r1636872 r1647397  
    44Requires at least: 4.0 
    55Tested up to: 4.7.3 
    6 Stable tag: 1.1.0 
     6Stable tag: 1.1.1 
    77License: GPLv3 or later 
    88License URI: http://www.gnu.org/licenses/gpl-3.0.html 
     
    100100== Changelog == 
    101101 
     102= 1.1.1 - 28-04-2017 = 
     103 
     104* [Fix] - Use 9 digit random IDs to prevent too big numbers for 32-bit systems 
     105* [Improvement] - Remove call to asset that no longer exists 
     106 
    102107= 1.1.0 - 06-03-2017 = IMPORTANT NOTE - As of this version, the plugin requires PHP 5.3 or higher to function 
    103108 
  • woocommerce-advanced-free-shipping/tags/1.1.1/woocommerce-advanced-free-shipping.php

    r1609491 r1647397  
    44 * Plugin URI:      https://wordpress.org/plugins/woocommerce-advanced-free-shipping/ 
    55 * Description:     WooCommerce Advanced Free Shipping is an plugin which allows you to set up advanced free shipping conditions. 
    6  * Version:         1.1.0 
     6 * Version:         1.1.1 
    77 * Author:          Jeroen Sormani 
    88 * Author URI:      http://jeroensormani.com/ 
     
    4949     * @var string $version Plugin version number. 
    5050     */ 
    51     public $version = '1.1.0'; 
     51    public $version = '1.1.1'; 
    5252 
    5353 
  • woocommerce-advanced-free-shipping/trunk/includes/admin/class-wafs-admin.php

    r1609491 r1647397  
    5555    public function admin_enqueue_scripts() { 
    5656 
    57         $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; 
    58  
    5957        wp_register_style( 'woocommerce-advanced-free-shipping', plugins_url( 'assets/css/woocommerce-advanced-free-shipping.min.css', WAFS()->file ), array(), WAFS()->version ); 
    60         wp_register_script( 'woocommerce-advanced-free-shipping', plugins_url( 'assets/js/woocommerce-advanced-free-shipping' . $suffix . '.js', WAFS()->file ), array( 'jquery' ), WAFS()->version, true ); 
    61         wp_localize_script( 'woocommerce-advanced-free-shipping', 'wafs', array( 
    62             'nonce' => wp_create_nonce( 'wpc-ajax-nonce' ), 
    63         ) ); 
    6458 
    6559        if ( 
     
    7468 
    7569            wp_enqueue_style( 'woocommerce-advanced-free-shipping' ); 
    76             wp_enqueue_script( 'woocommerce-advanced-free-shipping' ); 
    7770            wp_enqueue_script( 'wp-conditions' ); 
    7871 
  • woocommerce-advanced-free-shipping/trunk/includes/core-functions.php

    r1609491 r1647397  
    7979 
    8080} 
    81 add_action( 'wp-conditions\html_field_hook', 'wafs_add_bc_action_custom_fields' ); 
     81add_action( 'wp-conditions\html_field_hook', 'wafs_add_bc_action_custom_fields', 10, 2 ); 
  • woocommerce-advanced-free-shipping/trunk/libraries/wp-conditions/assets/js/wp-conditions.js

    r1609491 r1647397  
    3232    // Assign new ID to repeater row + open collapsible + re-enable nested repeater 
    3333    jQuery( document.body ).on( 'repeater-added-row', function( e, template, container, $self ) { 
    34         var new_id = Math.floor(Math.random()*8999999999+1000000000); // Random number sequence of 10 length 
     34        var new_id = Math.floor(Math.random()*899999999+100000000); // Random number sequence of 9 length 
    3535        template.find( 'input[name], select[name]' ).attr( 'name', function( index, value ) { 
    3636            return ( value.replace( '9999', new_id ) ) || value; 
     
    5656            condition_group_list = $( this ).parents( '.wpc-conditions' ), 
    5757            new_group            = condition_group_wrap.clone(), 
    58             new_group_id         = Math.floor(Math.random()*8999999999+1000000000); // Random number sequence of 10 length 
     58            new_group_id         = Math.floor(Math.random()*899999999+100000000); // Random number sequence of 9 length 
    5959 
    6060        // Fix dropdown selected not being cloned properly 
  • woocommerce-advanced-free-shipping/trunk/libraries/wp-conditions/assets/js/wp-conditions.min.js

    r1609491 r1647397  
    1 jQuery(function($){function t(){$(".wpc-conditions").parents(".postbox").repeater({addTrigger:".wpc-condition-group-add",removeTrigger:".wpc-condition-group .delete",template:".wpc-condition-group-template .wpc-condition-group-wrap",elementWrap:".wpc-condition-group-wrap",elementsContainer:".wpc-conditions",removeElement:function(t){t.remove()}})}function o(){$(".wpc-condition-group").repeater({addTrigger:".wpc-condition-add",removeTrigger:".wpc-condition-delete",template:".wpc-condition-template .wpc-condition-wrap",elementWrap:".wpc-condition-wrap",elementsContainer:".wpc-conditions-list"})}t(),o(),jQuery(document.body).on("repeater-added-row",function(t,e,n,i){var a=Math.floor(8999999999*Math.random()+1e9);e.find("input[name], select[name]").attr("name",function(t,o){return o.replace("9999",a)||o}),e.find(".wpc-condition[data-id]").attr("data-id",function(t,o){return o.replace("9999",a)||o}),e.find("[data-group]").attr("data-group",function(t,o){return o.replace("9999",a)||o}),e.find(".repeater-active").removeClass("repeater-active"),o()}),$(document.body).on("click",".wpc-conditions .duplicate",function(){var t=$(this).parents(".wpc-condition-group-wrap"),e=t.find(".wpc-condition-group").attr("data-group"),n=$(this).parents(".wpc-conditions"),i=t.clone(),a=Math.floor(8999999999*Math.random()+1e9);$(t).find("select").each(function(t){$(i).find("select").eq(t).val($(this).val())}),i.find(".wpc-condition-group").attr("data-group",a),i.find("input[name], select[name]").attr("name",function(t,o){return o.replace("conditions["+e+"]","conditions["+a+"]")}),i.find(".repeater-active").removeClass("repeater-active"),n.append(i),o(),$("html, body").on("scroll mousedown DOMMouseScroll mousewheel keydown touchmove",function(t){$("html, body").stop().off("scroll mousedown DOMMouseScroll mousewheel keydown touchmove")}),$("body, html").animate({scrollTop:$(i).offset().top-50},750,function(){$("html, body").off("scroll mousedown DOMMouseScroll mousewheel keydown touchmove")})}),$(document.body).on("change",".wpc-condition",function(){var t='<span style="width: calc( 42.5% - 75px ); border: 1px solid transparent; display: inline-block;">&nbsp;</span>',o={action:wpc2.action_prefix+"update_condition_value",id:$(this).attr("data-id"),group:$(this).parents(".wpc-condition-group").attr("data-group"),condition:$(this).val(),nonce:wpc.nonce},e=$(this).parents(".wpc-condition-wrap").first(),n=".wpc-value-field-wrap";e.find(n).html(t).block({message:null,overlayCSS:{background:"",opacity:.6}}),$.post(ajaxurl,o,function(t){e.find(n).replaceWith(t),$(document.body).trigger("wc-enhanced-select-init")});var i=e.find(".wpc-operator").val();e.find(".wpc-operator").empty().html(function(){var t=$(this),e=wpc.condition_operators[o.condition]||wpc.condition_operators["default"];$.each(e,function(o,e){t.append($("<option/>").attr("value",o).text(e)),t.val(i).val()||t.val(t.find("option:first").val())})}),e.find(".wpc-description").html(function(){return $('<span class="woocommerce-help-tip" />').attr("data-tip",wpc.condition_descriptions[o.condition]||"")}),$(".tips, .help_tip, .woocommerce-help-tip").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200}),$("#tiptip_holder").removeAttr("style"),$("#tiptip_arrow").removeAttr("style")}),$(".wpc-conditions-post-table.wpc-sortable-post-table tbody").sortable({items:"tr",handle:".sort",cursor:"move",axis:"y",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"wc-metabox-sortable-placeholder",start:function(t,o){o.item.css("background-color","#f6f6f6")},stop:function(t,o){o.item.removeAttr("style")},update:function(t,o){$table=$(this).closest("table"),$table.block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var e={action:"wpc_save_post_order",form:$(this).closest("form").serialize(),nonce:wpc.nonce};$.post(ajaxurl,e,function(t){$(".wpc-conditions-post-table tbody tr:even").addClass("alternate"),$(".wpc-conditions-post-table tbody tr:odd").removeClass("alternate"),$table.unblock()})}})}); 
     1jQuery(function($){function t(){$(".wpc-conditions").parents(".postbox").repeater({addTrigger:".wpc-condition-group-add",removeTrigger:".wpc-condition-group .delete",template:".wpc-condition-group-template .wpc-condition-group-wrap",elementWrap:".wpc-condition-group-wrap",elementsContainer:".wpc-conditions",removeElement:function(t){t.remove()}})}function o(){$(".wpc-condition-group").repeater({addTrigger:".wpc-condition-add",removeTrigger:".wpc-condition-delete",template:".wpc-condition-template .wpc-condition-wrap",elementWrap:".wpc-condition-wrap",elementsContainer:".wpc-conditions-list"})}t(),o(),jQuery(document.body).on("repeater-added-row",function(t,e,n,i){var a=Math.floor(899999999*Math.random()+1e8);e.find("input[name], select[name]").attr("name",function(t,o){return o.replace("9999",a)||o}),e.find(".wpc-condition[data-id]").attr("data-id",function(t,o){return o.replace("9999",a)||o}),e.find("[data-group]").attr("data-group",function(t,o){return o.replace("9999",a)||o}),e.find(".repeater-active").removeClass("repeater-active"),o()}),$(document.body).on("click",".wpc-conditions .duplicate",function(){var t=$(this).parents(".wpc-condition-group-wrap"),e=t.find(".wpc-condition-group").attr("data-group"),n=$(this).parents(".wpc-conditions"),i=t.clone(),a=Math.floor(899999999*Math.random()+1e8);$(t).find("select").each(function(t){$(i).find("select").eq(t).val($(this).val())}),i.find(".wpc-condition-group").attr("data-group",a),i.find("input[name], select[name]").attr("name",function(t,o){return o.replace("conditions["+e+"]","conditions["+a+"]")}),i.find(".repeater-active").removeClass("repeater-active"),n.append(i),o(),$("html, body").on("scroll mousedown DOMMouseScroll mousewheel keydown touchmove",function(t){$("html, body").stop().off("scroll mousedown DOMMouseScroll mousewheel keydown touchmove")}),$("body, html").animate({scrollTop:$(i).offset().top-50},750,function(){$("html, body").off("scroll mousedown DOMMouseScroll mousewheel keydown touchmove")})}),$(document.body).on("change",".wpc-condition",function(){var t='<span style="width: calc( 42.5% - 75px ); border: 1px solid transparent; display: inline-block;">&nbsp;</span>',o={action:wpc2.action_prefix+"update_condition_value",id:$(this).attr("data-id"),group:$(this).parents(".wpc-condition-group").attr("data-group"),condition:$(this).val(),nonce:wpc.nonce},e=$(this).parents(".wpc-condition-wrap").first(),n=".wpc-value-field-wrap";e.find(n).html(t).block({message:null,overlayCSS:{background:"",opacity:.6}}),$.post(ajaxurl,o,function(t){e.find(n).replaceWith(t),$(document.body).trigger("wc-enhanced-select-init")});var i=e.find(".wpc-operator").val();e.find(".wpc-operator").empty().html(function(){var t=$(this),e=wpc.condition_operators[o.condition]||wpc.condition_operators["default"];$.each(e,function(o,e){t.append($("<option/>").attr("value",o).text(e)),t.val(i).val()||t.val(t.find("option:first").val())})}),e.find(".wpc-description").html(function(){return $('<span class="woocommerce-help-tip" />').attr("data-tip",wpc.condition_descriptions[o.condition]||"")}),$(".tips, .help_tip, .woocommerce-help-tip").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200}),$("#tiptip_holder").removeAttr("style"),$("#tiptip_arrow").removeAttr("style")}),$(".wpc-conditions-post-table.wpc-sortable-post-table tbody").sortable({items:"tr",handle:".sort",cursor:"move",axis:"y",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"wc-metabox-sortable-placeholder",start:function(t,o){o.item.css("background-color","#f6f6f6")},stop:function(t,o){o.item.removeAttr("style")},update:function(t,o){$table=$(this).closest("table"),$table.block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var e={action:"wpc_save_post_order",form:$(this).closest("form").serialize(),nonce:wpc.nonce};$.post(ajaxurl,e,function(t){$(".wpc-conditions-post-table tbody tr:even").addClass("alternate"),$(".wpc-conditions-post-table tbody tr:odd").removeClass("alternate"),$table.unblock()})}})}); 
  • woocommerce-advanced-free-shipping/trunk/libraries/wp-conditions/conditions/wpc-city-condition.php

    r1609491 r1647397  
    1515        } 
    1616 
    17         // @todo - Check if this can be cleaned up 
    1817        public function match( $match, $operator, $value ) { 
    1918 
     
    2221 
    2322            if ( '==' == $operator ) : 
    24  
    25                 if ( preg_match( '/\, ?/', $value ) ) : 
    26                     $match = ( in_array( $customer_city, preg_split( '/\, ?/', $value ) ) ); 
    27                 else : 
    28                     $match = ( $value == $customer_city ); 
    29                 endif; 
    30  
     23                $match = ( in_array( $customer_city, preg_split( '/\, ?/', $value ) ) ); 
    3124            elseif ( '!=' == $operator ) : 
    32  
    33                 if ( preg_match( '/\, ?/', $value ) ) : 
    34                     $match = ( ! in_array( $customer_city, preg_split( '/\, ?/', $value ) ) ); 
    35                 else : 
    36                     $match = ( $value == $customer_city ); 
    37                 endif; 
    38  
     25                $match = ( ! in_array( $customer_city, preg_split( '/\, ?/', $value ) ) ); 
    3926            endif; 
    4027 
  • woocommerce-advanced-free-shipping/trunk/libraries/wp-conditions/conditions/wpc-condition.php

    r1609491 r1647397  
    9999        public function match( $match, $operator, $value ) { 
    100100 
     101            if ( ! $this->validate() ) { 
     102                return false; 
     103            } 
     104 
    101105            $value = $this->get_value( $value ); 
    102106            $compare_value = $this->get_compare_value(); 
     
    115119        } 
    116120 
     121        /** 
     122         * Validates before matching function. 
     123         * Can be used for example to verify the global $product exists. 
     124         */ 
     125        public function validate() { 
     126            return true; 
     127        } 
     128 
    117129        public function get_description() { 
    118130            return $this->description; 
  • woocommerce-advanced-free-shipping/trunk/libraries/wp-conditions/conditions/wpc-contains-product-condition.php

    r1609491 r1647397  
    3232 
    3333            $product_ids = array(); 
    34             foreach ( WC()->cart->cart_contents as $product ) : 
    35                 $product_ids[] = $product['product_id']; 
    36                 if ( isset( $product['variation_id'] ) ) { 
    37                     $product_ids[] = $product['variation_id']; 
     34            foreach ( WC()->cart->get_cart() as $item ) : 
     35                $product_ids[] = $item['product_id']; 
     36                if ( isset( $item['variation_id'] ) ) { 
     37                    $product_ids[] = $item['variation_id']; 
    3838                } 
    3939            endforeach; 
  • woocommerce-advanced-free-shipping/trunk/libraries/wp-conditions/conditions/wpc-coupon-condition.php

    r1609491 r1647397  
    6363            $coupons = array( 'percent' => array(), 'fixed' => array() ); 
    6464            foreach ( WC()->cart->get_coupons() as $coupon ) { 
    65                 $type               = str_replace( '_product', '', $coupon->discount_type ); 
    66                 $type               = str_replace( '_cart', '', $type ); 
    67                 $coupons[ $type ][] = $coupon->coupon_amount; 
     65                /** @var $coupon WC_Coupon */ 
     66                if ( version_compare( WC()->version, '2.7', '>=' ) ) { 
     67                    $type               = str_replace( '_product', '', $coupon->get_discount_type() ); 
     68                    $type               = str_replace( '_cart', '', $type ); 
     69                    $coupons[ $type ][] = $coupon->get_amount(); 
     70                } else { 
     71                    $type               = str_replace( '_product', '', $coupon->discount_type ); 
     72                    $type               = str_replace( '_cart', '', $type ); 
     73                    $coupons[ $type ][] = $coupon->coupon_amount; 
     74                } 
    6875            } 
    6976 
  • woocommerce-advanced-free-shipping/trunk/libraries/wp-conditions/conditions/wpc-height-condition.php

    r1609491 r1647397  
    1010            $this->slug        = __( 'height', 'wpc-conditions' ); 
    1111            $this->group       = __( 'Product', 'wpc-conditions' ); 
    12             $this->description = __( 'Compared to highest product in cart', 'wpc-conditions' ); 
     12            $this->description = __( 'Compared to the highest product in cart', 'wpc-conditions' ); 
    1313 
    1414            parent::__construct(); 
     
    1818 
    1919            $height = array(); 
    20             foreach ( WC()->cart->get_cart() as $product ) : 
     20            foreach ( WC()->cart->get_cart() as $item ) : 
    2121 
    22                 if ( true == $product['data']->variation_has_height ) : 
    23                     $height[] = ( get_post_meta( $product['data']->variation_id, '_height', true ) ); 
    24                 else : 
    25                     $height[] = ( get_post_meta( $product['product_id'], '_height', true ) ); 
    26                 endif; 
     22                /** @var $product WC_Product */ 
     23                $product = $item['data']; 
     24                $height[] = $product->get_height(); 
    2725 
    2826            endforeach; 
  • woocommerce-advanced-free-shipping/trunk/libraries/wp-conditions/conditions/wpc-length-condition.php

    r1609491 r1647397  
    1010            $this->slug        = __( 'length', 'wpc-conditions' ); 
    1111            $this->group       = __( 'Product', 'wpc-conditions' ); 
    12             $this->description = __( 'Compared to lengthiest product in cart', 'wpc-conditions' ); 
     12            $this->description = __( 'Compared to the lengthiest product in cart', 'wpc-conditions' ); 
    1313 
    1414            parent::__construct(); 
     
    1818 
    1919            $length = array(); 
    20             foreach ( WC()->cart->get_cart() as $product ) : 
     20            foreach ( WC()->cart->get_cart() as $item ) : 
    2121 
    22                 if ( true == $product['data']->variation_has_length ) : 
    23                     $length[] = ( get_post_meta( $product['data']->variation_id, '_length', true ) ); 
    24                 else : 
    25                     $length[] = ( get_post_meta( $product['product_id'], '_length', true ) ); 
    26                 endif; 
     22                /** @var $product WC_Product */ 
     23                $product = $item['data']; 
     24                $length[] = $product->get_length(); 
    2725 
    2826            endforeach; 
  • woocommerce-advanced-free-shipping/trunk/libraries/wp-conditions/conditions/wpc-role-condition.php

    r1609491 r1647397  
    3131 
    3232        public function get_compare_value() { 
    33             global $current_user; 
    34             return $current_user->caps; 
     33            if ( is_user_logged_in() ) { 
     34                global $current_user; 
     35                return $current_user->caps; 
     36            } else { 
     37                return array( 'not_logged_in' ); 
     38            } 
     39 
    3540        } 
    3641 
     
    4954 
    5055            $user_roles = array_keys( get_editable_roles() ); 
     56            $user_roles = array_combine( $user_roles, $user_roles ); 
     57            $user_roles['not_logged_in'] = __( 'Guest user', 'wp-conditions' ); 
    5158 
    5259            $field_args = array( 
    5360                'type' => 'select', 
    5461                'class' => array( 'wpc-value' ), 
    55                 'options' => array_combine( $user_roles, $user_roles ), 
     62                'options' => $user_roles, 
    5663            ); 
    5764 
  • woocommerce-advanced-free-shipping/trunk/libraries/wp-conditions/conditions/wpc-stock-condition.php

    r1609491 r1647397  
    2020 
    2121            // $package['contents'] 
    22             foreach ( WC()->cart->get_cart() as $product ) : 
     22            foreach ( WC()->cart->get_cart() as $item ) : 
    2323 
    24                 if ( true == $product['data']->variation_has_stock ) : 
    25                     $stock[] = ( get_post_meta( $product['data']->variation_id, '_stock', true ) ); 
    26                 else : 
    27                     $stock[] = ( get_post_meta( $product['product_id'], '_stock', true ) ); 
    28                 endif; 
     24                /** @var $product WC_Product */ 
     25                $product = $item['data']; 
     26                $stock[] = $product->get_stock_quantity(); 
    2927 
    3028            endforeach; 
  • woocommerce-advanced-free-shipping/trunk/libraries/wp-conditions/conditions/wpc-stock-status-condition.php

    r1609491 r1647397  
    2323                $match = true; 
    2424                // $package['contents'] 
    25                 foreach ( WC()->cart->get_cart() as $product ) : 
     25                foreach ( WC()->cart->get_cart() as $item ) : 
    2626 
    27                     if ( true == $product['data']->variation_has_stock ) : 
    28                         $stock_status = ( get_post_meta( $product['data']->variation_id, '_stock_status', true ) ); 
    29                     else : 
    30                         $stock_status = ( get_post_meta( $product['product_id'], '_stock_status', true ) ); 
    31                     endif; 
     27                    /** @var $product WC_Product */ 
     28                    $product = $item['data']; 
     29 
     30                    if ( method_exists( $product, 'get_stock_status' ) ) { // WC 2.7 compatibility 
     31                        $stock_status = $product->get_stock_status(); 
     32                    } else { // Pre 2.7 
     33                        $stock_status = $product->stock_status; 
     34                    } 
    3235 
    3336                    if ( $stock_status != $value ) : 
    34                         $match = false; 
     37                        return false; 
    3538                    endif; 
    3639 
     
    4144                $match = true; 
    4245                // $package['contents'] 
    43                 foreach ( WC()->cart->get_cart() as $product ) : 
     46                foreach ( WC()->cart->get_cart() as $item ) : 
    4447 
    45                     if ( true == $product['data']->variation_has_stock ) : 
    46                         $stock_status = ( get_post_meta( $product['data']->variation_id, '_stock_status', true ) ); 
    47                     else : 
    48                         $stock_status = ( get_post_meta( $product['product_id'], '_stock_status', true ) ); 
    49                     endif; 
     48                    /** @var $product WC_Product */ 
     49                    $product = $item['data']; 
     50 
     51                    if ( method_exists( $product, 'get_stock_status' ) ) { // WC 2.7 compatibility 
     52                        $stock_status = $product->get_stock_status(); 
     53                    } else { // Pre 2.7 
     54                        $stock_status = $product->stock_status; 
     55                    } 
    5056 
    5157                    if ( $stock_status == $value ) : 
    52                         $match = false; 
     58                        return false; 
    5359                    endif; 
    5460 
     
    5662 
    5763            endif; 
     64 
     65            return $match; 
    5866 
    5967        } 
     
    7078        } 
    7179 
     80        public function get_value_field_args() { 
     81 
     82            $field_args = array( 
     83                'type'    => 'select', 
     84                'options' => array( 
     85                    '1' => __( 'In stock', 'woocommerce' ), 
     86                    '0' => __( 'Out of stock', 'woocommerce' ), 
     87                ), 
     88            ); 
     89 
     90            return $field_args; 
     91 
     92        } 
     93 
    7294    } 
    7395 
  • woocommerce-advanced-free-shipping/trunk/libraries/wp-conditions/conditions/wpc-subtotal-condition.php

    r1609491 r1647397  
    1616 
    1717        public function get_value( $value ) { 
    18             // Make sure its formatted correct 
    1918            return str_replace( ',', '.', $value ); 
    2019        } 
  • woocommerce-advanced-free-shipping/trunk/libraries/wp-conditions/conditions/wpc-time-condition.php

    r1609491 r1647397  
    2828                'type' => 'text', 
    2929                'class' => array( 'wpc-value' ), 
    30                 'placeholder' => 'dd-mm-yyyy or yyyy-mm-dd', 
     30                'placeholder' => sprintf( __( 'Current time is: %s', 'woocommerce-advanced-messages' ), current_time( 'H:i' ) ), 
    3131            ); 
    3232 
  • woocommerce-advanced-free-shipping/trunk/libraries/wp-conditions/conditions/wpc-weight-condition.php

    r1609491 r1647397  
    1616 
    1717        public function get_value( $value ) { 
    18             // Make sure its formatted correct 
    1918            return str_replace( ',', '.', $value ); 
    2019        } 
  • woocommerce-advanced-free-shipping/trunk/libraries/wp-conditions/conditions/wpc-width-condition.php

    r1609491 r1647397  
    1010            $this->slug        = __( 'width', 'wpc-conditions' ); 
    1111            $this->group       = __( 'Product', 'wpc-conditions' ); 
    12             $this->description = __( 'Compared to widest product in cart', 'wpc-conditions' ); 
     12            $this->description = __( 'Compared to the widest product in cart', 'wpc-conditions' ); 
    1313 
    1414            parent::__construct(); 
     
    1818 
    1919            $width = array(); 
    20             foreach ( WC()->cart->get_cart() as $product ) : 
     20            foreach ( WC()->cart->get_cart() as $item ) : 
    2121 
    22                 if ( true == $product['data']->variation_has_width ) : 
    23                     $width[] = ( get_post_meta( $product['data']->variation_id, '_width', true ) ); 
    24                 else : 
    25                     $width[] = ( get_post_meta( $product['product_id'], '_width', true ) ); 
    26                 endif; 
     22                /** @var $product WC_Product */ 
     23                $product = $item['data']; 
     24                $width[] = $product->get_width(); 
    2725 
    2826            endforeach; 
  • woocommerce-advanced-free-shipping/trunk/libraries/wp-conditions/conditions/wpc-zipcode-condition.php

    r1609491 r1647397  
    1818 
    1919            $zipcode = $this->get_compare_value(); 
    20  
    21             // Prepare the store-owner set value 
    22             $value_zipcodes = array(); 
    23             if ( preg_match( '/\, ?/', $value ) ) : 
    24  
    25                 foreach ( preg_split( '/\, ?/', $value ) as $v ) : 
    26                     $value_zipcodes[] = preg_replace( '/[^0-9a-zA-Z\-]/', '', $v ); 
    27                 endforeach; 
    28  
    29             else : 
    30                 $value_zipcodes[] = preg_replace( '/[^0-9a-zA-Z\-]/', '', $value ); 
    31             endif; 
     20            $value_zipcodes = $this->get_value( $value ); 
    3221 
    3322            // Match zipcode 
     
    4433                $match = true; 
    4534                foreach ( $value_zipcodes as $zip ) : 
    46                     if ( $match = ! preg_match( '/^' . preg_quote( $zip, '/' ) . '/i', $zipcode ) ) : 
     35                    if ( preg_match( '/^' . preg_quote( $zip, '/' ) . '/i', $zipcode ) ) : 
     36                        return $match = false; 
    4737                        break; 
    4838                    endif; 
     
    7363        } 
    7464 
     65        public function get_value( $value ) { 
     66 
     67            $value_zipcodes = array(); 
     68            foreach ( preg_split( '/\, ?/', $value ) as $v ) : 
     69                $value_zipcodes[] = preg_replace( '/[^0-9a-zA-Z\-]/', '', $v ); 
     70            endforeach; 
     71 
     72            return $value_zipcodes; 
     73 
     74        } 
     75 
    7576        public function get_compare_value() { 
    7677            return preg_replace( '/[^0-9a-zA-Z\-]/', '', WC()->customer->get_shipping_postcode() ); 
  • woocommerce-advanced-free-shipping/trunk/libraries/wp-conditions/functions.php

    r1609491 r1647397  
    3333require_once 'conditions/wpc-role-condition.php'; 
    3434 
     35// Product (cart based) 
    3536require_once 'conditions/wpc-length-condition.php'; 
    3637require_once 'conditions/wpc-width-condition.php'; 
     
    3940require_once 'conditions/wpc-stock-condition.php'; 
    4041require_once 'conditions/wpc-category-condition.php'; 
    41  
     42require_once 'conditions/wpc-volume-condition.php'; 
     43 
     44// Product (single based) 
     45require_once 'conditions/wpc-product-condition.php'; 
     46require_once 'conditions/wpc-product-age-condition.php'; 
     47require_once 'conditions/wpc-product-type-condition.php'; 
     48require_once 'conditions/wpc-product-category-condition.php'; 
     49require_once 'conditions/wpc-product-shipping-class-condition.php'; 
     50require_once 'conditions/wpc-product-tag-condition.php'; 
     51require_once 'conditions/wpc-product-height-condition.php'; 
     52require_once 'conditions/wpc-product-length-condition.php'; 
     53require_once 'conditions/wpc-product-price-condition.php'; 
     54require_once 'conditions/wpc-product-sale-price-condition.php'; 
     55require_once 'conditions/wpc-product-stock-condition.php'; 
     56require_once 'conditions/wpc-product-stock-status-condition.php'; 
     57require_once 'conditions/wpc-product-width-condition.php'; 
     58require_once 'conditions/wpc-product-sales-condition.php'; 
     59require_once 'conditions/wpc-product-on-sale-condition.php'; 
    4260 
    4361if ( ! function_exists( 'wpc_get_registered_conditions' ) ) { 
     
    7997            new WPC_Stock_Condition(), 
    8098            new WPC_Category_Condition(), 
     99            new WPC_Volume_Condition(), 
     100 
     101            new WPC_Product_Condition(), 
     102            new WPC_Product_Age_Condition(), 
     103            new WPC_Product_Type_Condition(), 
     104            new WPC_Product_Length_Condition(), 
     105            new WPC_Product_Width_Condition(), 
     106            new WPC_Product_Height_Condition(), 
     107            new WPC_Product_Stock_Status_Condition(), 
     108            new WPC_Product_Stock_Condition(), 
     109            new WPC_Product_Category_Condition(), 
     110            new WPC_Product_Shipping_Class_Condition(), 
     111            new WPC_Product_Tag_Condition(), 
     112            new WPC_Product_Price_Condition(), 
     113            new WPC_Product_Sale_Price_Condition(), 
     114            new WPC_Product_Sales_Condition(), 
     115            new WPC_Product_On_Sale_Condition(), 
    81116        ); 
    82117 
     
    103138 
    104139        $class_name = 'WPC_' . implode( '_', array_map( 'ucfirst', explode( '_', $condition ) ) ) . '_Condition'; 
     140        $class_name = apply_filters( 'wpc_get_condition_class_name', $class_name, $condition ); 
     141 
    105142        if ( class_exists( $class_name ) ) { 
    106143            return new $class_name(); 
  • woocommerce-advanced-free-shipping/trunk/readme.txt

    r1636872 r1647397  
    44Requires at least: 4.0 
    55Tested up to: 4.7.3 
    6 Stable tag: 1.1.0 
     6Stable tag: 1.1.1 
    77License: GPLv3 or later 
    88License URI: http://www.gnu.org/licenses/gpl-3.0.html 
     
    100100== Changelog == 
    101101 
     102= 1.1.1 - 28-04-2017 = 
     103 
     104* [Fix] - Use 9 digit random IDs to prevent too big numbers for 32-bit systems 
     105* [Improvement] - Remove call to asset that no longer exists 
     106 
    102107= 1.1.0 - 06-03-2017 = IMPORTANT NOTE - As of this version, the plugin requires PHP 5.3 or higher to function 
    103108 
  • woocommerce-advanced-free-shipping/trunk/woocommerce-advanced-free-shipping.php

    r1609491 r1647397  
    44 * Plugin URI:      https://wordpress.org/plugins/woocommerce-advanced-free-shipping/ 
    55 * Description:     WooCommerce Advanced Free Shipping is an plugin which allows you to set up advanced free shipping conditions. 
    6  * Version:         1.1.0 
     6 * Version:         1.1.1 
    77 * Author:          Jeroen Sormani 
    88 * Author URI:      http://jeroensormani.com/ 
     
    4949     * @var string $version Plugin version number. 
    5050     */ 
    51     public $version = '1.1.0'; 
     51    public $version = '1.1.1'; 
    5252 
    5353 
Note: See TracChangeset for help on using the changeset viewer.