Plugin Directory

Changeset 2678892


Ignore:
Timestamp:
02/15/2022 08:50:32 AM (4 years ago)
Author:
peterlogisnap
Message:

Updates shipping methods

Location:
logisnap
Files:
37 added
3 edited

Legend:

Unmodified
Added
Removed
  • logisnap/trunk/LogiSnap.php

    r2672047 r2678892  
    33 * Plugin Name: LogiSnap
    44 * Description: Easily integrate your LogiSnap solution into Woocommerce.
    5  * Version: 1.0.1
     5 * Version: 1.0.2
    66 * Author: LogiSnap
    77 * Author URI: //LogiSnap.com
     
    2929
    3030    /** @var $*/
    31     public $version = '1.0.1';
     31    public $version = '1.0.2';
    3232
    3333    /** @var LSS_Options */
  • logisnap/trunk/includes/class-lss-shipping.php

    r2597913 r2678892  
    101101                   
    102102                    $this->instance_form_fields['carrier'] = [
    103                         'title'         => __( 'Shipping Method', 'logisnap-shipping-for-woocommerce' ),
     103                        'title'         => __( 'Select Carrier', 'logisnap-shipping-for-woocommerce' ),
    104104                        'type'          => 'select',
    105105                        'class'         => '',
    106                         'description'   => __( 'Which carrier this shipping method should apply to', 'logisnap-shipping-for-woocommerce' ),
    107106                        'options'       => $options
    108107                    ];
    109108
    110109                    $this->instance_form_fields['type'] = [
    111                         'title'         => __( 'Product', 'logisnap-shipping-for-woocommerce' ),
     110                        'title'         => __( 'Shipment Type', 'logisnap-shipping-for-woocommerce' ),
    112111                        'type'          => 'select',
    113112                        'class'         => 'lss_product_type_field',
    114                         'description'   => __( 'Which Carrier product type to use', 'logisnap-shipping-for-woocommerce' ),
    115113                        'options'       => $type_options
    116114                    ];
     
    118116
    119117                    $this->instance_form_fields['cost'] = [
    120                         'title'             => __( 'Cost', 'woocommerce' ),
     118                        'title'             => __( 'Shipping Price', 'woocommerce' ),
    121119                        'type'              => 'text',
    122120                        'placeholder'       => '',
     
    134132                    ];
    135133
     134                    $this->instance_form_fields['reduce_shipping_price'] = [
     135                        'title'             => __( 'Reduce Shipping Price By %', 'woocommerce' ),
     136                        'type'              => 'text',
     137                        'placeholder'       => '',
     138                        'default'           => '0',
     139                        'sanitize_callback' => array( $this, 'sanitize_cost' )
     140                    ];
     141
     142
     143                    $this->instance_form_fields['reduce_shipping_price_condition'] = [
     144                        'title'             => __( 'Condition', 'woocommerce' ),
     145                        'type'              => 'select',
     146                        'placeholder'       => '',
     147                        'default'           => '0',
     148                        'sanitize_callback' => array( $this, 'sanitize_cost' ),
     149                        'options'           => $this->get_conditions()
     150                    ];
     151
     152                    $this->instance_form_fields['reduce_shipping_condition_amount'] = [
     153                        'title'             => __( 'Amount', 'woocommerce' ),
     154                        'type'              => 'text',
     155                        'placeholder'       => '',
     156                        'default'           => '0',
     157                        'sanitize_callback' => array( $this, 'sanitize_cost' )
     158                    ];
     159
    136160                    // when changing position
    137161                    // change index in admin enque js
     162                       // 'When cart is below a price',
     163                       // 'When cart is above a price',
    138164                    $coupon_optionsArray = [
    139                        'When cart is below a price',
    140                        'When cart is above a price',
    141165                       'Cut shipping price by procent',
    142166                       'Cut shipping price by amount',
     
    149173                        'type'          => 'select',
    150174                        'class'         => 'lss_coupon_options_field',
    151                         'description'   => __( 'What should happen when free coupon is applied',
    152                                                 'logisnap-shipping-for-woocommerce' ),
    153175                        'options'       => $coupon_optionsArray,
    154176                        'sanitize_callback' => array( $this, 'sanitize_cost' )
     
    164186                    ];
    165187                }
     188            }
     189
     190            function get_conditions(){
     191                // when changing position
     192                // change index in admin enque js
     193                $condiction = [
     194                   'When cart is above amount',
     195                   'When cart is below amount'
     196                ];
     197                return $condiction;
    166198            }
    167199
     
    317349                }
    318350
     351                $reduce_choice = $this->get_option('reduce_shipping_price_condition');
     352                $cart_price = $package['contents_cost'];
     353
     354
     355                if($reduce_choice == 0){
     356                    $reduce_amount = $this->get_option( 'reduce_shipping_price' );
     357                    $reduce_condition_amount = $this->get_option( 'reduce_shipping_condition_amount' );
     358
     359                    if($reduce_condition_amount < $cart_price)
     360                        $rate['cost'] -= ($rate['cost'] / 100) * $reduce_amount;
     361                }
     362                else if($reduce_choice == 1){
     363                    $reduce_amount = $this->get_option( 'reduce_shipping_price' );
     364                    $reduce_condition_amount = $this->get_option( 'reduce_shipping_condition_amount' );
     365
     366                    if($reduce_condition_amount > $cart_price)
     367                        $rate['cost'] -= ($rate['cost'] / 100) * $reduce_amount;
     368                }
     369
     370
    319371                if($free_shipping_coupon)
    320372                {
    321373                    $coupon_choice = $this->get_option( 'coupon_options' );
    322                     $cart_price = $package['contents_cost'];
    323374
    324375                    if($coupon_choice == 0)
    325                     {   
    326                         // check if the price is lower then selected
    327                         if($this->get_option( 'coupon_amount' ) > $cart_price)
    328                             $rate['cost'] = 0;
    329                     }
    330                     else if($coupon_choice == 1)
    331                     {
    332                         // check if the price is higher then selected
    333                         if($this->get_option( 'coupon_amount' ) < $cart_price)
    334                             $rate['cost'] = 0;
    335                     }
    336                     else if($coupon_choice == 2)
    337376                    {
    338377                        $rate['cost'] -= ($rate['cost'] / 100) * $this->get_option( 'coupon_amount' );
    339378                    }
    340                     else if($coupon_choice == 3){
     379                    else if($coupon_choice == 1){
    341380
    342381                        $rate['cost'] -= $this->get_option( 'coupon_amount' );
    343382                    }
    344                     else if($coupon_choice == 4){
     383                    else if($coupon_choice == 2){
    345384
    346385                        $rate['cost'] = 0;
     
    426465                            // if free shipping is selected hide the amount field
    427466                            // or if dont apply free coupon is selected
    428                             if(valueOption == 4 || valueOption == 5){
     467                            if(valueOption == 2 || valueOption == 3){
    429468                                minAmountField.hide();
    430469                               
  • logisnap/trunk/readme.txt

    r2672041 r2678892  
    55Requires at least: 5.0
    66Tested up to: 5.8
    7 Stable tag: 1.0.1
     7Stable tag: 1.0.2
    88Requires PHP: 5.6.0
    99Requires WooCommerce: 3.0.0
     
    2323
    2424== Changelog ==
     25
     26= 1.0.2 =
     27* Added more options for the shipping methods
     28* Updated shipment method pop up
     29
    2530= 1.0.1 =
    2631* Updated endpoints
Note: See TracChangeset for help on using the changeset viewer.