Plugin Directory

Changeset 2986171


Ignore:
Timestamp:
10/30/2023 02:19:35 PM (2 years ago)
Author:
redboxsa
Message:

Version 1.31

Location:
redbox-pickup
Files:
5 edited
8 copied

Legend:

Unmodified
Added
Removed
  • redbox-pickup/tags/1.31/css/front.css

    r2678417 r2986171  
    8989  height: auto;
    9090  border-radius: 3px;
     91  display: flex;
     92  height: 100%;
    9193}
    9294.list-point .per-point {
     
    101103    box-shadow: 0 4px 12px rgb(42 65 232 / 15%);
    102104    background: #fff;
    103     height: 100%;
     105    max-height: calc(100% - 20px);
     106    margin: auto;
     107    overflow: auto;
    104108}
    105109.list-point .per-point .step1{
  • redbox-pickup/tags/1.31/front/front.php

    r2821828 r2986171  
    1414
    1515            private function redbox_get_data_customer($order) {
     16                $shippingFirstName = $order->get_shipping_first_name();
     17                $shippingLastName = $order->get_shipping_last_name();
     18                $shippingPhone = $order->get_shipping_phone();
     19                $shippingAddress = $order->get_shipping_address_1();
     20
    1621                $billingFirstName = $order->get_billing_first_name();
    1722                $billingLastName = $order->get_billing_last_name();
    1823                $billingPhone = $order->get_billing_phone();
    1924                $billingEmail = $order->get_billing_email();
     25                $billingAddress = $order->get_billing_address_1();
    2026
    2127                $data = [
    22                     "name" => $billingFirstName . ' ' . $billingLastName,
    23                     'phone' => $billingPhone,
     28                    "name" => $shippingFirstName ? $shippingFirstName . ' ' . $shippingLastName : $billingFirstName . ' ' . $billingLastName,
     29                    'phone' => $shippingPhone ? $shippingPhone : $billingPhone,
    2430                    'email' => $billingEmail,
    25                     'adddress' => $order->get_billing_address_1()
     31                    'adddress' => $shippingAddress ? $shippingAddress : $billingAddress
    2632                ];
    2733                return $data;
     
    122128            }
    123129
    124             function redbox_create_shipment( $order_id, $posted_data, $order ) {
     130            function redbox_create_shipment( $order_id) {
     131                $order = new WC_Order( $order_id );
    125132                $note = 'Creating redbox shipments';
    126133                $order->add_order_note( $note );
     
    138145                    "store_url" => get_home_url(),
    139146                    "reference" => $order_id,
    140                     "point_id" => $_POST['redbox_point_id'],
     147                    "point_id" => $order->get_meta( '_redbox_point_id' ),
    141148                    "customer_name" => $customerData['name'],
    142149                    "customer_phone" => $customerData['phone'],
     
    150157                    "from_platform" => "woo_commerce"
    151158                ];
     159                $dataShipment["is_paid"] = $order->is_paid();
     160                $dataShipment["get_payment_method"] = $order->get_payment_method();
    152161                if ($order->get_payment_method() == "cod") {
    153                     $dataShipment['cod_amount'] = $priceData['order_total'];
    154                     $dataShipment['cod_currency'] = $priceData['curency'];
    155                 } else {
    156                     $dataShipment['cod_amount'] = 0;
    157                     $dataShipment['cod_currency'] = $priceData['curency'];
    158                 }
     162                    $dataShipment['cod_amount'] = $priceData['order_total'];
     163                    $dataShipment['cod_currency'] = $priceData['curency'];
     164                } else {
     165                    if ($order->is_paid()) {
     166                        $dataShipment['cod_amount'] = 0;
     167                        $dataShipment['cod_currency'] = $priceData['curency'];
     168                    } else {
     169                        $dataShipment['cod_amount'] = 10;
     170                        $dataShipment['cod_currency'] = "USD";
     171                    }
     172                }
    159173                if ($this->redbox_validate_body_create_shipment($dataShipment)) {
    160174                    $urlQuery = REDBOX_URL_CREATE_SHIPMENT;
     
    296310
    297311            function bbloomer_woocommerce_tiered_shipping( $rates, $package ) {
    298                 if ($this->minimumAmount == false) {
    299                     return $rates;
    300                 }
    301                 $total = WC()->cart->subtotal;
    302                 if ($total >= $this->minimumAmount) {
    303                     if ($rates["redbox_pickup_delivery"]) {
    304                         $rates["redbox_pickup_delivery"]->cost = 0;
    305                         $rates["redbox_pickup_delivery"]->taxes = 0;
    306                     }
    307                 }
    308                 return $rates;
     312                // if ($this->minimumAmount == false) {
     313                //  return $rates;
     314                // }
     315                // $total = WC()->cart->subtotal;
     316                // if ($total >= $this->minimumAmount) {
     317                //  if ($rates["redbox_pickup_delivery"]) {
     318                //      $rates["redbox_pickup_delivery"]->cost = 0;
     319                //      $rates["redbox_pickup_delivery"]->taxes = 0;
     320                //  }
     321                // }
     322                // return $rates;
     323                $no_free_shipping_method = false;
     324                if($no_free_shipping_method == true):
     325                    $new_rates = array();
     326                    foreach ( $rates as $rate_id => $rate ) {
     327                        // Only modify rates if free_shipping is present.
     328                        if ( 'free_shipping' != $rate->method_id ) {
     329                            $new_rates[ $rate_id ] = $rate;
     330                            break;
     331                        }
     332                    }
     333                else:
     334                    $new_rates = array();
     335                    foreach ( $rates as $rate_id => $rate ) {
     336                        // Only modify rates if free_shipping is present.
     337                        if ( 'free_shipping' === $rate->method_id || 'redbox_pickup_delivery' === $rate->method_id) {
     338                            $new_rates[ $rate_id ] = $rate;
     339                            break;
     340                        }
     341                    }
     342                endif;
     343
     344
     345                if ( ! empty( $new_rates ) ) {
     346                    //Save local pickup if it's present.
     347                    foreach ( $rates as $rate_id => $rate ) {
     348                        if ('local_pickup' === $rate->method_id ) {
     349                            $new_rates[ $rate_id ] = $rate;
     350                            break;
     351                        }
     352                    }
     353                    return $new_rates;
     354                }
     355
     356                return $rates;
    309357            }
    310358
     
    313361                add_action('wp_ajax_getlispoint', array( $this, 'redbox_get_list_point' ));
    314362                add_action('wp_ajax_nopriv_getlispoint', array( $this, 'redbox_get_list_point' ));
    315                 add_action('woocommerce_checkout_order_processed', array( $this, 'redbox_create_shipment' ), 10, 3);
     363                add_action('woocommerce_thankyou', array( $this, 'redbox_create_shipment' ));
    316364                add_action( 'woocommerce_after_checkout_billing_form', array($this, 'redbox_add_point_field') );
    317365
  • redbox-pickup/tags/1.31/js/front.js

    r2768963 r2986171  
    146146                if (data.success) {
    147147                    REDBOX_LIST_POINT = data.points
    148                     activeInputConfirm()
    149148                    drawMapInThis(data.points, lat, lng)
    150149                    jQuery('.redbox-waiting-response').remove()
     
    164163            let LNG = 46.6752957
    165164            if (REDBOX_LIST_POINT.length) {
    166                 activeInputConfirm()
    167165                drawMapInThis(REDBOX_LIST_POINT, LAT, LNG)
    168166                jQuery('.redbox-waiting-response').remove()
     
    352350    function reRenderMapWithPoint(lat, lng) {
    353351        var htmlWaiting = '<div class="redbox-waiting-response"><i class="fa fa-spinner fa-spin"></i></div>'
    354         var bounds = new google.maps.LatLngBounds();
    355         bounds.extend(new google.maps.LatLng(lat, lng));
    356         bounds.extend(new google.maps.LatLng(REDBOX_LIST_POINT[0].location.lat, REDBOX_LIST_POINT[0].location.lng));
    357         REDBOX_MAP.fitBounds(bounds);
     352        // var bounds = new google.maps.LatLngBounds();
     353        // bounds.extend(new google.maps.LatLng(lat, lng));
     354        // bounds.extend(new google.maps.LatLng(REDBOX_LIST_POINT[0].location.lat, REDBOX_LIST_POINT[0].location.lng));
     355        // REDBOX_MAP.fitBounds(bounds);
     356        if (lat && lng) {
     357            REDBOX_MAP.setCenter(new google.maps.LatLng(lat, lng))
     358            REDBOX_MAP.setZoom(17);
     359        }
    358360        jQuery( "#wrap-area-choose-point" ).animate({
    359361            bottom: -400
     
    392394                activeLabelPoint()
    393395                setClickCloseChoosePoint()
     396                activeInputConfirm()
    394397            }
    395398        });
  • redbox-pickup/tags/1.31/readme.txt

    r2821828 r2986171  
    55Requires at least: 3.3
    66Tested up to: 5.5.1
    7 Stable tag: 1.30
     7Stable tag: 1.31
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • redbox-pickup/tags/1.31/redbox.php

    r2821828 r2986171  
    44        * Description: This plugin allows customers pickup package at RedBox Locker.
    55        * Plugin URI: https://woocommerce.com/
    6         * Version: 1.30
     6        * Version: 1.31
    77        * Author: RedBox
    88        * Author URI: https://redboxsa.com
     
    131131                wp_enqueue_style( 'redbox_font_roboto', 'https://fonts.googleapis.com/css?family=Roboto' );
    132132                wp_enqueue_style( 'redbox_font_cario', 'https://fonts.googleapis.com/css?family=Cairo' );
    133                 wp_enqueue_script( 'redbox_front_js', REDBOX_PLUGIN_DIR . '/js/front.js', false, '1.0.20' );
     133                wp_enqueue_script( 'redbox_front_js', REDBOX_PLUGIN_DIR . '/js/front.js', false, '1.0.21' );
    134134                wp_enqueue_script( 'redbox_front_js_map', 'https://maps.googleapis.com/maps/api/js?key=AIzaSyBY1xlGe6jLbugOJegCsUGnzlufYWa5CRw&amp;sensor=false&amp;libraries=places' );
    135135                wp_enqueue_script( 'redbox_front_js_map_clustor', 'https://unpkg.com/@google/markerclustererplus@4.0.1/dist/markerclustererplus.min.js' );
  • redbox-pickup/trunk/css/front.css

    r2678417 r2986171  
    8989  height: auto;
    9090  border-radius: 3px;
     91  display: flex;
     92  height: 100%;
    9193}
    9294.list-point .per-point {
     
    101103    box-shadow: 0 4px 12px rgb(42 65 232 / 15%);
    102104    background: #fff;
    103     height: 100%;
     105    max-height: calc(100% - 20px);
     106    margin: auto;
     107    overflow: auto;
    104108}
    105109.list-point .per-point .step1{
  • redbox-pickup/trunk/front/front.php

    r2821828 r2986171  
    1414
    1515            private function redbox_get_data_customer($order) {
     16                $shippingFirstName = $order->get_shipping_first_name();
     17                $shippingLastName = $order->get_shipping_last_name();
     18                $shippingPhone = $order->get_shipping_phone();
     19                $shippingAddress = $order->get_shipping_address_1();
     20
    1621                $billingFirstName = $order->get_billing_first_name();
    1722                $billingLastName = $order->get_billing_last_name();
    1823                $billingPhone = $order->get_billing_phone();
    1924                $billingEmail = $order->get_billing_email();
     25                $billingAddress = $order->get_billing_address_1();
    2026
    2127                $data = [
    22                     "name" => $billingFirstName . ' ' . $billingLastName,
    23                     'phone' => $billingPhone,
     28                    "name" => $shippingFirstName ? $shippingFirstName . ' ' . $shippingLastName : $billingFirstName . ' ' . $billingLastName,
     29                    'phone' => $shippingPhone ? $shippingPhone : $billingPhone,
    2430                    'email' => $billingEmail,
    25                     'adddress' => $order->get_billing_address_1()
     31                    'adddress' => $shippingAddress ? $shippingAddress : $billingAddress
    2632                ];
    2733                return $data;
     
    122128            }
    123129
    124             function redbox_create_shipment( $order_id, $posted_data, $order ) {
     130            function redbox_create_shipment( $order_id) {
     131                $order = new WC_Order( $order_id );
    125132                $note = 'Creating redbox shipments';
    126133                $order->add_order_note( $note );
     
    138145                    "store_url" => get_home_url(),
    139146                    "reference" => $order_id,
    140                     "point_id" => $_POST['redbox_point_id'],
     147                    "point_id" => $order->get_meta( '_redbox_point_id' ),
    141148                    "customer_name" => $customerData['name'],
    142149                    "customer_phone" => $customerData['phone'],
     
    150157                    "from_platform" => "woo_commerce"
    151158                ];
     159                $dataShipment["is_paid"] = $order->is_paid();
     160                $dataShipment["get_payment_method"] = $order->get_payment_method();
    152161                if ($order->get_payment_method() == "cod") {
    153                     $dataShipment['cod_amount'] = $priceData['order_total'];
    154                     $dataShipment['cod_currency'] = $priceData['curency'];
    155                 } else {
    156                     $dataShipment['cod_amount'] = 0;
    157                     $dataShipment['cod_currency'] = $priceData['curency'];
    158                 }
     162                    $dataShipment['cod_amount'] = $priceData['order_total'];
     163                    $dataShipment['cod_currency'] = $priceData['curency'];
     164                } else {
     165                    if ($order->is_paid()) {
     166                        $dataShipment['cod_amount'] = 0;
     167                        $dataShipment['cod_currency'] = $priceData['curency'];
     168                    } else {
     169                        $dataShipment['cod_amount'] = 10;
     170                        $dataShipment['cod_currency'] = "USD";
     171                    }
     172                }
    159173                if ($this->redbox_validate_body_create_shipment($dataShipment)) {
    160174                    $urlQuery = REDBOX_URL_CREATE_SHIPMENT;
     
    296310
    297311            function bbloomer_woocommerce_tiered_shipping( $rates, $package ) {
    298                 if ($this->minimumAmount == false) {
    299                     return $rates;
    300                 }
    301                 $total = WC()->cart->subtotal;
    302                 if ($total >= $this->minimumAmount) {
    303                     if ($rates["redbox_pickup_delivery"]) {
    304                         $rates["redbox_pickup_delivery"]->cost = 0;
    305                         $rates["redbox_pickup_delivery"]->taxes = 0;
    306                     }
    307                 }
    308                 return $rates;
     312                // if ($this->minimumAmount == false) {
     313                //  return $rates;
     314                // }
     315                // $total = WC()->cart->subtotal;
     316                // if ($total >= $this->minimumAmount) {
     317                //  if ($rates["redbox_pickup_delivery"]) {
     318                //      $rates["redbox_pickup_delivery"]->cost = 0;
     319                //      $rates["redbox_pickup_delivery"]->taxes = 0;
     320                //  }
     321                // }
     322                // return $rates;
     323                $no_free_shipping_method = false;
     324                if($no_free_shipping_method == true):
     325                    $new_rates = array();
     326                    foreach ( $rates as $rate_id => $rate ) {
     327                        // Only modify rates if free_shipping is present.
     328                        if ( 'free_shipping' != $rate->method_id ) {
     329                            $new_rates[ $rate_id ] = $rate;
     330                            break;
     331                        }
     332                    }
     333                else:
     334                    $new_rates = array();
     335                    foreach ( $rates as $rate_id => $rate ) {
     336                        // Only modify rates if free_shipping is present.
     337                        if ( 'free_shipping' === $rate->method_id || 'redbox_pickup_delivery' === $rate->method_id) {
     338                            $new_rates[ $rate_id ] = $rate;
     339                            break;
     340                        }
     341                    }
     342                endif;
     343
     344
     345                if ( ! empty( $new_rates ) ) {
     346                    //Save local pickup if it's present.
     347                    foreach ( $rates as $rate_id => $rate ) {
     348                        if ('local_pickup' === $rate->method_id ) {
     349                            $new_rates[ $rate_id ] = $rate;
     350                            break;
     351                        }
     352                    }
     353                    return $new_rates;
     354                }
     355
     356                return $rates;
    309357            }
    310358
     
    313361                add_action('wp_ajax_getlispoint', array( $this, 'redbox_get_list_point' ));
    314362                add_action('wp_ajax_nopriv_getlispoint', array( $this, 'redbox_get_list_point' ));
    315                 add_action('woocommerce_checkout_order_processed', array( $this, 'redbox_create_shipment' ), 10, 3);
     363                add_action('woocommerce_thankyou', array( $this, 'redbox_create_shipment' ));
    316364                add_action( 'woocommerce_after_checkout_billing_form', array($this, 'redbox_add_point_field') );
    317365
  • redbox-pickup/trunk/js/front.js

    r2768963 r2986171  
    146146                if (data.success) {
    147147                    REDBOX_LIST_POINT = data.points
    148                     activeInputConfirm()
    149148                    drawMapInThis(data.points, lat, lng)
    150149                    jQuery('.redbox-waiting-response').remove()
     
    164163            let LNG = 46.6752957
    165164            if (REDBOX_LIST_POINT.length) {
    166                 activeInputConfirm()
    167165                drawMapInThis(REDBOX_LIST_POINT, LAT, LNG)
    168166                jQuery('.redbox-waiting-response').remove()
     
    352350    function reRenderMapWithPoint(lat, lng) {
    353351        var htmlWaiting = '<div class="redbox-waiting-response"><i class="fa fa-spinner fa-spin"></i></div>'
    354         var bounds = new google.maps.LatLngBounds();
    355         bounds.extend(new google.maps.LatLng(lat, lng));
    356         bounds.extend(new google.maps.LatLng(REDBOX_LIST_POINT[0].location.lat, REDBOX_LIST_POINT[0].location.lng));
    357         REDBOX_MAP.fitBounds(bounds);
     352        // var bounds = new google.maps.LatLngBounds();
     353        // bounds.extend(new google.maps.LatLng(lat, lng));
     354        // bounds.extend(new google.maps.LatLng(REDBOX_LIST_POINT[0].location.lat, REDBOX_LIST_POINT[0].location.lng));
     355        // REDBOX_MAP.fitBounds(bounds);
     356        if (lat && lng) {
     357            REDBOX_MAP.setCenter(new google.maps.LatLng(lat, lng))
     358            REDBOX_MAP.setZoom(17);
     359        }
    358360        jQuery( "#wrap-area-choose-point" ).animate({
    359361            bottom: -400
     
    392394                activeLabelPoint()
    393395                setClickCloseChoosePoint()
     396                activeInputConfirm()
    394397            }
    395398        });
  • redbox-pickup/trunk/readme.txt

    r2821828 r2986171  
    55Requires at least: 3.3
    66Tested up to: 5.5.1
    7 Stable tag: 1.30
     7Stable tag: 1.31
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • redbox-pickup/trunk/redbox.php

    r2821828 r2986171  
    44        * Description: This plugin allows customers pickup package at RedBox Locker.
    55        * Plugin URI: https://woocommerce.com/
    6         * Version: 1.30
     6        * Version: 1.31
    77        * Author: RedBox
    88        * Author URI: https://redboxsa.com
     
    131131                wp_enqueue_style( 'redbox_font_roboto', 'https://fonts.googleapis.com/css?family=Roboto' );
    132132                wp_enqueue_style( 'redbox_font_cario', 'https://fonts.googleapis.com/css?family=Cairo' );
    133                 wp_enqueue_script( 'redbox_front_js', REDBOX_PLUGIN_DIR . '/js/front.js', false, '1.0.20' );
     133                wp_enqueue_script( 'redbox_front_js', REDBOX_PLUGIN_DIR . '/js/front.js', false, '1.0.21' );
    134134                wp_enqueue_script( 'redbox_front_js_map', 'https://maps.googleapis.com/maps/api/js?key=AIzaSyBY1xlGe6jLbugOJegCsUGnzlufYWa5CRw&amp;sensor=false&amp;libraries=places' );
    135135                wp_enqueue_script( 'redbox_front_js_map_clustor', 'https://unpkg.com/@google/markerclustererplus@4.0.1/dist/markerclustererplus.min.js' );
Note: See TracChangeset for help on using the changeset viewer.