Plugin Directory

Changeset 2465699


Ignore:
Timestamp:
01/30/2021 10:02:12 PM (5 years ago)
Author:
invisibledragonltd
Message:

Update to version 1.2.2 from GitLab (https://gitlab.com/invisibledragon/id-delivery; https://gitlab.com/invisibledragon/id-delivery/-/jobs/997251037)

Location:
deliveryplus-by-invisible-dragon
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • deliveryplus-by-invisible-dragon/tags/1.2.2/bin/deploy.sh

    r2251671 r2465699  
    66# it does not exit with a 0, and I only care about the final exit.
    77set -eo
     8
     9# TODO: Move to a function to pull out of id-delivery.php
     10env PLUGIN_VERSION=1.3
    811
    912# Common cleanup actions.
  • deliveryplus-by-invisible-dragon/tags/1.2.2/class.DeliveryPlus_Shipping_Method.php

    r2402544 r2465699  
    5353                'default'       => '0.00',
    5454                'desc_tip'      => true
    55             ),
    56             'filter' => array(
    57                 'title'         => __('Filter'),
    58                 'type'          => 'deliveryplus_filter',
    59                 'description'   => __('Add filtering rules to determine if this rate is to be displayed on the page'),
    60                 'default'       => '[]',
    61                 'context'       => 'shipping_method'
    6255            )
    63         );
     56        );
     57
     58        // Shipping classes
     59        if($instance_id > 0) {
     60            $shipping_classes = WC()->shipping()->get_shipping_classes();
     61            if (!empty($shipping_classes)) {
     62                foreach ($shipping_classes as $shipping_class) {
     63                    if (!isset($shipping_class->term_id)) {
     64                        continue;
     65                    }
     66                    $this->instance_form_fields['class_cost_' . $shipping_class->term_id] = array(
     67                        'title' => sprintf(__('"%s" shipping class cost'), esc_html($shipping_class->name)),
     68                        'type' => 'text',
     69                        'placeholder' => __('N/A'),
     70                        'description' => __('This cost will be added for each item which has this shipping class')
     71                    );
     72                }
     73
     74            }
     75        }
     76
     77        $this->instance_form_fields['filter'] = array(
     78            'title'         => __('Filter'),
     79            'type'          => 'deliveryplus_filter',
     80            'description'   => __('Add filtering rules to determine if this rate is to be displayed on the page'),
     81            'default'       => '[]',
     82            'context'       => 'shipping_method'
     83        );
    6484
    6585        // GravityForms Integration
     
    156176        if($this->instance_id == sanitize_text_field($_GET['instance_id'])) {
    157177
    158             if( acf_validate_save_post(true) ) {
    159                 acf_save_post( "woo_ship_" . $this->instance_id );
    160             }
     178            if( function_exists('acf_validate_save_post') ) { // ACF may not be installed
     179                if (acf_validate_save_post(true)) {
     180                    acf_save_post("woo_ship_" . $this->instance_id);
     181                }
     182            }
    161183
    162184        }
     
    290312        $total_flat_area = 0;
    291313
     314        $additional_cost = 0;
     315
    292316        foreach ( $package['contents'] as $item_id => $values ) {
    293317            if ( $values['quantity'] > 0 && $values['data']->needs_shipping() ) {
     
    311335                $weight = $prod->get_weight('edit');
    312336                if($weight){ $total_weight += $weight * $values['quantity']; }
     337
     338                $shipping_class = $values['data']->get_shipping_class();
     339                if(!empty($shipping_class)) {
     340                    $shipping_class = get_term_by( 'slug', $shipping_class, 'product_shipping_class' );
     341                    $charge = $this->get_option( 'class_cost_' . $shipping_class->term_id );
     342                    if($charge) {
     343                        $additional_cost += $charge * $values['quantity'];
     344                    }
     345                }
    313346            }
    314347        }
     
    363396
    364397        // Do the math.
    365         return $sum ? WC_Eval_Math::evaluate( $sum ) : 0;
     398        return ($sum ? WC_Eval_Math::evaluate( $sum ) : 0) + $additional_cost;
    366399
    367400    }
  • deliveryplus-by-invisible-dragon/tags/1.2.2/id-delivery.php

    r2403850 r2465699  
    77Author URI: https://invisibledragonltd.com/
    88License: Private
    9 Version: 1.2.1
     9Version: 1.3
    1010Requires PHP: 5.6
    1111
    12 WC requires at least: 3.9
    13 WC tested up to: 4.6.0
     12WC requires at least: 4.6
     13WC tested up to: 5.0
    1414*/
    1515
    16 define('ID_DELIVERY_VERSION', '1.2');
     16define('ID_DELIVERY_VERSION', '1.3');
    1717
    1818add_action( 'plugins_loaded', array( 'DeliveryPlusPlugin', 'get_instance' ) );
  • deliveryplus-by-invisible-dragon/tags/1.2.2/readme.txt

    r2403850 r2465699  
    6565= 1.2.1 =
    6666* Bugfix
     67
     68= 1.3 =
     69* Actually works without Advanced Custom Fields
     70* Rate per each shipping class
    6771 
    6872== Upgrade Notice ==
  • deliveryplus-by-invisible-dragon/tags/1.2.2/tests/test-replacements.php

    r2282505 r2465699  
    1414    public function get_height($mode){ return 3; }
    1515    public function get_length($mode){ return 4; }
     16    public function get_shipping_class(){}
    1617
    1718}
  • deliveryplus-by-invisible-dragon/trunk/bin/deploy.sh

    r2251671 r2465699  
    66# it does not exit with a 0, and I only care about the final exit.
    77set -eo
     8
     9# TODO: Move to a function to pull out of id-delivery.php
     10env PLUGIN_VERSION=1.3
    811
    912# Common cleanup actions.
  • deliveryplus-by-invisible-dragon/trunk/class.DeliveryPlus_Shipping_Method.php

    r2402544 r2465699  
    5353                'default'       => '0.00',
    5454                'desc_tip'      => true
    55             ),
    56             'filter' => array(
    57                 'title'         => __('Filter'),
    58                 'type'          => 'deliveryplus_filter',
    59                 'description'   => __('Add filtering rules to determine if this rate is to be displayed on the page'),
    60                 'default'       => '[]',
    61                 'context'       => 'shipping_method'
    6255            )
    63         );
     56        );
     57
     58        // Shipping classes
     59        if($instance_id > 0) {
     60            $shipping_classes = WC()->shipping()->get_shipping_classes();
     61            if (!empty($shipping_classes)) {
     62                foreach ($shipping_classes as $shipping_class) {
     63                    if (!isset($shipping_class->term_id)) {
     64                        continue;
     65                    }
     66                    $this->instance_form_fields['class_cost_' . $shipping_class->term_id] = array(
     67                        'title' => sprintf(__('"%s" shipping class cost'), esc_html($shipping_class->name)),
     68                        'type' => 'text',
     69                        'placeholder' => __('N/A'),
     70                        'description' => __('This cost will be added for each item which has this shipping class')
     71                    );
     72                }
     73
     74            }
     75        }
     76
     77        $this->instance_form_fields['filter'] = array(
     78            'title'         => __('Filter'),
     79            'type'          => 'deliveryplus_filter',
     80            'description'   => __('Add filtering rules to determine if this rate is to be displayed on the page'),
     81            'default'       => '[]',
     82            'context'       => 'shipping_method'
     83        );
    6484
    6585        // GravityForms Integration
     
    156176        if($this->instance_id == sanitize_text_field($_GET['instance_id'])) {
    157177
    158             if( acf_validate_save_post(true) ) {
    159                 acf_save_post( "woo_ship_" . $this->instance_id );
    160             }
     178            if( function_exists('acf_validate_save_post') ) { // ACF may not be installed
     179                if (acf_validate_save_post(true)) {
     180                    acf_save_post("woo_ship_" . $this->instance_id);
     181                }
     182            }
    161183
    162184        }
     
    290312        $total_flat_area = 0;
    291313
     314        $additional_cost = 0;
     315
    292316        foreach ( $package['contents'] as $item_id => $values ) {
    293317            if ( $values['quantity'] > 0 && $values['data']->needs_shipping() ) {
     
    311335                $weight = $prod->get_weight('edit');
    312336                if($weight){ $total_weight += $weight * $values['quantity']; }
     337
     338                $shipping_class = $values['data']->get_shipping_class();
     339                if(!empty($shipping_class)) {
     340                    $shipping_class = get_term_by( 'slug', $shipping_class, 'product_shipping_class' );
     341                    $charge = $this->get_option( 'class_cost_' . $shipping_class->term_id );
     342                    if($charge) {
     343                        $additional_cost += $charge * $values['quantity'];
     344                    }
     345                }
    313346            }
    314347        }
     
    363396
    364397        // Do the math.
    365         return $sum ? WC_Eval_Math::evaluate( $sum ) : 0;
     398        return ($sum ? WC_Eval_Math::evaluate( $sum ) : 0) + $additional_cost;
    366399
    367400    }
  • deliveryplus-by-invisible-dragon/trunk/id-delivery.php

    r2403850 r2465699  
    77Author URI: https://invisibledragonltd.com/
    88License: Private
    9 Version: 1.2.1
     9Version: 1.3
    1010Requires PHP: 5.6
    1111
    12 WC requires at least: 3.9
    13 WC tested up to: 4.6.0
     12WC requires at least: 4.6
     13WC tested up to: 5.0
    1414*/
    1515
    16 define('ID_DELIVERY_VERSION', '1.2');
     16define('ID_DELIVERY_VERSION', '1.3');
    1717
    1818add_action( 'plugins_loaded', array( 'DeliveryPlusPlugin', 'get_instance' ) );
  • deliveryplus-by-invisible-dragon/trunk/readme.txt

    r2403850 r2465699  
    6565= 1.2.1 =
    6666* Bugfix
     67
     68= 1.3 =
     69* Actually works without Advanced Custom Fields
     70* Rate per each shipping class
    6771 
    6872== Upgrade Notice ==
  • deliveryplus-by-invisible-dragon/trunk/tests/test-replacements.php

    r2282505 r2465699  
    1414    public function get_height($mode){ return 3; }
    1515    public function get_length($mode){ return 4; }
     16    public function get_shipping_class(){}
    1617
    1718}
Note: See TracChangeset for help on using the changeset viewer.