Plugin Directory

Changeset 3122791


Ignore:
Timestamp:
07/21/2024 04:18:14 PM (21 months ago)
Author:
boxnow
Message:

minor function changes

Location:
box-now-delivery/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • box-now-delivery/trunk/box-now-delivery.php

    r3002071 r3122791  
    55Author: BOX NOW
    66Text Domain: box-now-delivery
    7 Version: 2.1
     7Version: 2.1.2
    88*/
    99
     
    360360    "allowReturn" => true,
    361361    "origin" => [
     362      "contactNumber" => get_option('boxnow_mobile_number', ''),
    362363      "contactEmail" => get_option('boxnow_voucher_email', ''),
    363364      "locationId" => $prep_data['selected_warehouse'],
     
    394395      $order->save();
    395396    } else {
    396       throw new Exception('Error: Unable to create vouchers.');
     397      throw new Exception('Error: Unable to create vouchers.' . json_encode($response_body));
    397398    }
    398399    return wp_remote_retrieve_body($response);
     
    509510// Ensure the country's prefix is not missing
    510511$tel = $prep_data['phone'];
    511 if (substr($tel, 0, 1) != '+' && substr($tel, 0, 2) != '00') {
    512     $numberOfDigits = strlen(preg_replace('/[^\d]/', '', $tel));
    513     $firstTwoDigits = substr($tel, 0, 2);
    514       if ($numberOfDigits < 9 && in_array($firstTwoDigits, ['22', '23', '24', '25', '26', '96', '97', '98', '99'])) {
    515         $tel = '+357' . $tel;
    516 }     
    517       else {
    518         $tel = '+30' . $tel;
    519 }
    520   }
     512if (substr($tel, 0, 1) != '+') {
     513  // If the phone starts with "00", replace "00" with "+"
     514  if (substr($tel, 0, 2) === '00') {
     515      $tel = '+' . substr($tel, 2);
     516  }
     517  // If the phone starts with the specified codes and has less than 9 digits, put "+357" in the beginning
     518  elseif (in_array(substr($tel, 0, 2), ['22', '23', '24', '25', '26', '96', '97', '98', '99']) && strlen(preg_replace('/[^\d]/', '', $tel)) < 9) {
     519      $tel = '+357' . preg_replace('/[^\d]/', '', $tel);
     520  }
     521  else {
     522      $tel = '+30' . preg_replace('/[^\d]/', '', $tel);
     523  }
     524}
    521525$prep_data['phone'] = $tel;
    522526
     
    564568    "allowReturn" => true,
    565569    "origin" => [
     570      "contactNumber" => get_option('boxnow_mobile_number', ''),
    566571      "contactEmail" => get_option('boxnow_voucher_email', ''),
    567572      "locationId" => $prep_data['selected_warehouse'],
     
    599604    } else {
    600605      error_log('API Response: ' . print_r($response_body, true));
    601       throw new Exception('Error: Unable to create vouchers.');
     606      throw new Exception('Error: Unable to create vouchers.'. json_encode($response_body));
    602607    }
    603608    return wp_remote_retrieve_body($response);
  • box-now-delivery/trunk/includes/box-now-delivery-admin-page.php

    r3002071 r3122791  
    154154            </p>
    155155          </div>
     156            <!-- Sender's Contact field -->
     157            <h2 style="width: 100%; float: left;">Sender's Contact field</h2>
     158          <div style="width: 30%; float: left;">
     159            <p>
     160              <label>Sender's Phone(Will be used for returns):</label>
     161              <br />
     162              <input type="text" name="boxnow_mobile_number" value="<?php echo esc_attr(get_option('boxnow_mobile_number', '')); ?>" placeholder="Enter your phone with country preffix (+30 , +357, etc)" />
     163            </p>
     164          </div>
    156165
    157166          <!-- Save button -->
  • box-now-delivery/trunk/includes/box-now-delivery-validation.php

    r2956661 r3122791  
    5656      update_option('boxnow_voucher_email', sanitize_email($_POST['boxnow_voucher_email']));
    5757    }
     58    if (isset($_POST['boxnow_mobile_number'])) {
     59      update_option('boxnow_mobile_number', sanitize_text_field($_POST['boxnow_mobile_number']));
     60    }
    5861    if (isset($_POST['boxnow_locker_not_selected_message'])) {
    5962      update_option('boxnow_locker_not_selected_message', sanitize_text_field($_POST['boxnow_locker_not_selected_message']));
  • box-now-delivery/trunk/js/box-now-delivery.js

    r3003253 r3122791  
    395395
    396396        if (
    397           (!lockerData &&
    398             $(
    399               'input[type="radio"][name="shipping_method[0]"]:checked'
    400             ).val() === "box_now_delivery") ||
    401           $("input[name='shipping_method[0]']").length == 1
     397          !lockerData &&
     398          $('input[type="radio"][name="shipping_method[0]"]:checked').val() ===
     399            "box_now_delivery"
    402400        ) {
    403401          event.preventDefault();
  • box-now-delivery/trunk/readme.txt

    r3002071 r3122791  
    33Tags: delivery, boxnow
    44Requires at least: 6.2
    5 Tested up to: 6.4.1
    6 Stable tag: 2.1
     5Tested up to: 6.6
     6Stable tag: 2.1.2
    77Requires PHP: 8.0
    88License: GPLv2 or later
     
    1717== Changelog ==
    1818
    19 = 2.1 =
    20 *Added Cyprus map+utility
     19= 2.1.2 =
     20*Added Sender's contact phone
    2121*Added Phone "check and fix" for cyprus and greek numbers
    22 *Added Sender's email field for "create voucher via a button"
    23 *Fixed a bug where boxnow wouldnt show if it was the only delivery service
    24 *Fixed a bug where admin was prompted to only define max weight in kilograms
     22*Minor Bug fixes
    2523
    2624== Upgrade Notice ==
    2725
    28 = 2.1 =
     26= 2.1.2 =
    2927Please upgrade to our latest plugin version to avoid coflicts and errors of any older versions.
Note: See TracChangeset for help on using the changeset viewer.