Plugin Directory

Changeset 3397364


Ignore:
Timestamp:
11/17/2025 03:43:01 PM (4 months ago)
Author:
hamsalam
Message:

1.3.6

Location:
sync-basalam/trunk
Files:
4 added
5 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • sync-basalam/trunk/includes/class-sync-basalam-plugin.php

    r3397293 r3397364  
    44class SyncBasalamPlugin
    55{
    6     const VERSION = '1.5.6';
     6    const VERSION = '1.5.5';
    77
    88    public function __construct()
     
    154154    private function initHooks()
    155155    {
     156
    156157        add_action('admin_menu', array('SyncBasalamMenus', 'registerMenus'));
    157158
  • sync-basalam/trunk/includes/services/class-sync-basalam-order-manager.php

    r3397293 r3397364  
    152152                $city      = $data['customer_data']['city']['title'] ?? '';
    153153
     154                $stateCode = SyncBasalamGetProvincesData::getCodeByName($province);
     155
     156                if ($stateCode) {
     157                    $order->set_billing_state($stateCode);
     158                    $order->set_shipping_state($stateCode);
     159                }
     160
    154161                $full_name = $recipient['name'] ?? '';
    155162                $first_name = '';
     
    161168                }
    162169
    163                 // Set basic billing info
    164170                $order->set_billing_first_name($first_name);
    165171                $order->set_billing_last_name($last_name);
    166172                $order->set_billing_address_1($recipient['postal_address'] ?? '');
     173                $order->set_billing_city($city);
    167174                $order->set_billing_postcode($recipient['postal_code'] ?? '');
    168175                $order->set_billing_country('IR');
    169176                $order->set_billing_phone($recipient['mobile'] ?? '');
    170177
    171                 // Set basic shipping info
    172178                $order->set_shipping_first_name($first_name);
    173179                $order->set_shipping_last_name($last_name);
    174180                $order->set_shipping_address_1($recipient['postal_address'] ?? '');
     181                $order->set_shipping_city($city);
    175182                $order->set_shipping_postcode($recipient['postal_code'] ?? '');
    176183                $order->set_shipping_phone($recipient['mobile'] ?? '');
    177184                $order->set_shipping_country('IR');
    178 
    179                 // Set state and city with PWS compatibility
    180                 $addressData = [
    181                     'province' => $province,
    182                     'city' => $city,
    183                 ];
    184                 SyncBasalamGetProvincesData::setOrderAddress($order, $addressData, 'billing');
    185                 SyncBasalamGetProvincesData::setOrderAddress($order, $addressData, 'shipping');
    186185
    187186                $default_method = SyncBasalamAdminSettings::getSettings(SyncBasalamAdminSettings::ORDER_SHIPPING_METHOD);
  • sync-basalam/trunk/includes/utilities/class-sync-basalam-get-provinces-data.php

    r3397293 r3397364  
    5050        return self::$provinces[$code] ?? null;
    5151    }
    52 
    53     /**
    54      * Check if Persian WooCommerce Shipping plugin is active
    55      */
    56     public static function isPWSActive(): bool
    57     {
    58         if (!function_exists('is_plugin_active')) {
    59             include_once(ABSPATH . 'wp-admin/includes/plugin.php');
    60         }
    61         return is_plugin_active('persian-woocommerce-shipping/persian-woocommerce-shipping.php');
    62     }
    63 
    64     /**
    65      * Set order address with PWS compatibility
    66      * If PWS is active, sets Tapin state/city IDs as meta data
    67      * Otherwise, uses normal WooCommerce state/city fields
    68      */
    69     public static function setOrderAddress($order, $addressData, $type = 'billing')
    70     {
    71         if (!$order || !isset($addressData['province']) || !isset($addressData['city'])) {
    72             return;
    73         }
    74 
    75         $province = trim($addressData['province']);
    76         $city = trim($addressData['city']);
    77 
    78         if (self::isPWSActive()) {
    79             // PWS is active - set Tapin IDs
    80             $state_id = self::getTapinStateIdByName($province);
    81             $city_id = self::getTapinCityIdByName($city, $state_id);
    82 
    83             if ($state_id) {
    84                 $order->update_meta_data("_{$type}_state_id", $state_id);
    85                 // Also set the state name for WooCommerce
    86                 if ($type === 'billing') {
    87                     $order->set_billing_state($province);
    88                 } else {
    89                     $order->set_shipping_state($province);
    90                 }
    91             }
    92 
    93             if ($city_id) {
    94                 $order->update_meta_data("_{$type}_city_id", $city_id);
    95                 // Also set the city name for WooCommerce
    96                 if ($type === 'billing') {
    97                     $order->set_billing_city($city);
    98                 } else {
    99                     $order->set_shipping_city($city);
    100                 }
    101             }
    102         } else {
    103             // PWS is not active - use normal WooCommerce fields
    104             if ($type === 'billing') {
    105                 $order->set_billing_state($province);
    106                 $order->set_billing_city($city);
    107             } else {
    108                 $order->set_shipping_state($province);
    109                 $order->set_shipping_city($city);
    110             }
    111         }
    112     }
    113 
    114     /**
    115      * Get Tapin state ID by Persian name
    116      */
    117     private static function getTapinStateIdByName($stateName): ?int
    118     {
    119         if (!class_exists('PWS_Tapin')) {
    120             return null;
    121         }
    122 
    123         $states = PWS_Tapin::states();
    124         if (!$states) {
    125             return null;
    126         }
    127 
    128         $stateName = trim($stateName);
    129         foreach ($states as $state_id => $state_title) {
    130             if (trim($state_title) === $stateName) {
    131                 return (int) $state_id;
    132             }
    133         }
    134 
    135         return null;
    136     }
    137 
    138     /**
    139      * Get Tapin city ID by Persian name
    140      */
    141     private static function getTapinCityIdByName($cityName, $stateId = null): ?int
    142     {
    143         if (!class_exists('PWS_Tapin')) {
    144             return null;
    145         }
    146 
    147         $cities = PWS_Tapin::cities($stateId);
    148         if (!$cities) {
    149             return null;
    150         }
    151 
    152         $cityName = trim($cityName);
    153         foreach ($cities as $city_id => $city_title) {
    154             if (trim($city_title) === $cityName) {
    155                 return (int) $city_id;
    156             }
    157         }
    158 
    159         return null;
    160     }
    16152}
  • sync-basalam/trunk/readme.txt

    r3397293 r3397364  
    55Tested up to: 6.8
    66Requires PHP: 7.4
    7 Stable tag: 1.5.6
     7Stable tag: 1.5.5
    88License: GPL-2.0-or-later 
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html 
  • sync-basalam/trunk/sync-basalam.php

    r3397293 r3397364  
    55 * Plugin Name: sync basalam | ووسلام
    66 * Description: با استفاده از پلاگین ووسلام  میتوایند تمامی محصولات ووکامرس را با یک کلیک به غرفه باسلامی خود اضافه کنید‌، همچنین تمامی سفارش باسلامی شما به سایت شما اضافه میگردد.
    7  * Version: 1.5.6
     7 * Version: 1.5.6-dev
    88 * Author: Woosalam Dev
    99 * Author URI: https://wp.hamsalam.ir/
  • sync-basalam/trunk/templates/admin/menu/main/main-connected.php

    r3397293 r3397364  
    1818$single_update_count = $job_manager->getCountJobs(['job_type' => 'sync_basalam_update_single_product', 'status' => ['pending', 'processing']]);
    1919
    20 $has_active_update_jobs = ($quick_update_processing_job || $full_update_job || $full_update_processing_job || $single_update_count > 0);
     20$has_active_update_jobs = ($quick_update_processing_job || $full_update_job || $full_update_processing_job || $single_update_count > 0 || $count_quick_update_batches > 0);
    2121$active_update_type = '';
    2222if ($quick_update_processing_job) {
Note: See TracChangeset for help on using the changeset viewer.