Plugin Directory

Changeset 3344313


Ignore:
Timestamp:
08/14/2025 05:46:18 AM (8 months ago)
Author:
buildecomteam
Message:

uppppdate

Location:
buildecom/trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • buildecom/trunk/buildecom.php

    r3344056 r3344313  
    77 * Plugin URI: https://buildecom.app/wp-plugin/
    88 * Description: The official WordPress plugin for BuildEcom. Build eCommerce mobile application through woocommerce and wordpress
    9  * Version: 1.0.7
     9 * Version: 1.0.8
    1010 * Author: BuildEcom
    1111 * Author URI: https://buildecom.app
  • buildecom/trunk/inc/api/class-api-controller.php

    r3319894 r3344313  
    906906        $user = $this->getUser();
    907907
     908        $user_id = $user ? $user->ID : 0;
     909
    908910        if (!$user) {
    909911            return buildecom_response_error('authentication_error', 'User is not authenticated', [], 401);
     
    912914        $params     = $request->get_body_params();
    913915
    914         $first_name = sanitize_text_field($params['first_name']);
    915         $last_name  = sanitize_text_field($params['last_name']);
    916         $phone      = sanitize_text_field($params['phone']);
    917         $address    = sanitize_text_field($params['address']);
    918         $city       = sanitize_text_field($params['city']);
    919         $state      = sanitize_text_field($params['state']);
    920         $postcode   = sanitize_text_field($params['postcode']);
    921         $country    = sanitize_text_field($params['country']);
     916        $first_name = sanitize_text_field($params['first_name'] ?? '');
     917        $last_name  = sanitize_text_field($params['last_name'] ?? '');
     918        $phone      = sanitize_text_field($params['phone'] ?? '');
     919        $address    = sanitize_text_field($params['address'] ?? '');
     920        $city       = sanitize_text_field($params['city'] ?? '');
     921        $state      = sanitize_text_field($params['state'] ?? '');
     922        $postcode   = sanitize_text_field($params['postcode'] ?? '');
     923        $country    = sanitize_text_field($params['country'] ?? '');
    922924
    923925        if (empty($first_name) || empty($last_name)) {
     
    984986                return buildecom_response_error('invalid_file_type', 'Only JPG, JPEG, and PNG files are allowed', [], 400);
    985987            }
    986         } else {
    987             return buildecom_response_error('no_file_uploaded', 'No file was uploaded', [], 400);
    988         }
     988        } 
    989989
    990990        return buildecom_response_success('profile_updated', 'Profile updated successfully');
  • buildecom/trunk/inc/helpers.php

    r3316130 r3344313  
    11<?php
    22
    3 if (!defined('ABSPATH')) exit;
     3if (!defined('ABSPATH'))
     4    exit;
    45
    56
     
    7980    function buildecom_generate_password_reset_token()
    8081    {
    81         $characters   = '0123456789';
     82        $characters = '0123456789';
    8283        $randomString = '';
    8384
     
    8687        }
    8788
    88         return  $randomString;
     89        return $randomString;
    8990    }
    9091}
     
    106107    {
    107108        $response = [
    108             'status'     => 'error',
    109             'remark'     => $remark,
    110             'message'    => ['error' => is_array($message) ? $message : [$message]],
     109            'status' => 'error',
     110            'remark' => $remark,
     111            'message' => ['error' => is_array($message) ? $message : [$message]],
    111112            ...$data
    112113        ];
     
    120121    function buildecom_get_formatted_date($time = false)
    121122    {
    122         if (! $time) {
     123        if (!$time) {
    123124            $time = strtotime('now');
    124125        }
     
    135136
    136137
    137 if (! function_exists('buildecom_wp_timezone')) {
     138if (!function_exists('buildecom_wp_timezone')) {
    138139    function buildecom_wp_timezone()
    139140    {
     
    143144
    144145
    145 if (! function_exists('buildecom_wp_timezone_string')) {
     146if (!function_exists('buildecom_wp_timezone_string')) {
    146147    function buildecom_wp_timezone_string()
    147148    {
     
    152153        }
    153154
    154         $offset  = (float) get_option('gmt_offset');
    155         $hours   = (int) $offset;
     155        $offset = (float) get_option('gmt_offset');
     156        $hours = (int) $offset;
    156157        $minutes = ($offset - $hours);
    157158
    158         $sign      = ($offset < 0) ? '-' : '+';
    159         $abs_hour  = abs($hours);
    160         $abs_mins  = abs($minutes * 60);
     159        $sign = ($offset < 0) ? '-' : '+';
     160        $abs_hour = abs($hours);
     161        $abs_mins = abs($minutes * 60);
    161162        $tz_offset = sprintf('%s%02d:%02d', $sign, $abs_hour, $abs_mins);
    162163
     
    170171    {
    171172        $response = [
    172             'status'     => 'success',
    173             'remark'     => $remark,
    174             'message'    => ['success' => is_array($message) ? $message : [$message]],
     173            'status' => 'success',
     174            'remark' => $remark,
     175            'message' => ['success' => is_array($message) ? $message : [$message]],
    175176            ...$data
    176177        ];
     
    195196    {
    196197
    197         $all_roles   = wp_roles()->roles;
     198        $all_roles = wp_roles()->roles;
    198199        $roles_array = array();
    199200
     
    216217    function buildecom_get_new_code_expiration_time($valid_seconds = 900)
    217218    {
    218         $time_string   = '+' . $valid_seconds . ' seconds';
     219        $time_string = '+' . $valid_seconds . ' seconds';
    219220        return strtotime($time_string);
    220221    }
     
    223224    function buildecom_send_password_reset_code_email($email = false, $code = false, $expiry = 0)
    224225    {
    225         if (! $email) {
     226        if (!$email) {
    226227            throw new Exception(esc_html__('An email address is required for the reset code email.', 'buildecom'));
    227228        }
    228229
    229         if (! $code) {
     230        if (!$code) {
    230231            throw new Exception(esc_html__('No code was provided for the password reset email.', 'buildecom'));
    231232        }
     
    237238            include $template_path;
    238239        } else {
    239             echo esc_html__( 'A password reset was requested for your account. Your code: ', 'buildecom' ) . esc_html( $code );
     240            echo esc_html__('A password reset was requested for your account. Your code: ', 'buildecom') . esc_html($code);
    240241        }
    241242
     
    246247        $html_message = apply_filters('buildecom_code_email_text', $html_message, $email, $code, $expiry);
    247248
    248         $siteName  = get_bloginfo('name');
    249         $mailFrom  = get_option('admin_email');
    250         $headers   = [];
     249        $siteName = get_bloginfo('name');
     250        $mailFrom = get_option('admin_email');
     251        $headers = [];
    251252        $headers[] = "From: $siteName <$mailFrom>";
    252253        $headers[] = "Reply-To: $siteName <$mailFrom>";
     
    300301
    301302        $userInfo = [
    302             'id'       => $user->ID,
    303             'email'    => $user->user_email,
     303            'id' => $user->ID,
     304            'email' => $user->user_email,
    304305            'fullname' => $user->display_name,
    305306            'username' => $user->user_login
     
    310311        }
    311312
    312         $userInfo             = buildecom_to_object($userInfo);
    313         $shortCodes           = array_merge($shortCodes ?? [], $globalShortCodes);
    314         $notify               = new Buildecom_Notify($sendVia);
     313        $userInfo = buildecom_to_object($userInfo);
     314        $shortCodes = array_merge($shortCodes ?? [], $globalShortCodes);
     315        $notify = new Buildecom_Notify($sendVia);
    315316        $notify->templateName = $templateName;
    316         $notify->shortCodes   = $shortCodes;
    317         $notify->user         = $userInfo;
    318         $notify->createLog    = $createLog;
     317        $notify->shortCodes = $shortCodes;
     318        $notify->user = $userInfo;
     319        $notify->createLog = $createLog;
    319320        $notify->send();
    320321    }
     
    349350    {
    350351        $args = [
    351             'method'    => 'POST',
    352             'body'      => is_array($postData) ? wp_json_encode($postData) : $postData,
    353             'headers'   => array_merge(['Content-Type' => 'application/json'], $headers),
     352            'method' => 'POST',
     353            'body' => is_array($postData) ? wp_json_encode($postData) : $postData,
     354            'headers' => array_merge(['Content-Type' => 'application/json'], $headers),
    354355            'sslverify' => true
    355356        ];
     
    374375        if ($order) {
    375376            $shortCodesArr = [
    376                 'status'               => $order->get_status(),
    377                 'currency'             => $order->get_currency(),
    378                 'shipping_tax'         => $order->get_shipping_tax(),
    379                 'total'                => $order->get_total(),
    380                 'total_tax'            => $order->get_total_tax(),
    381                 'order_key'            => $order->get_order_key(),
    382                 'billing_first_name'   => $order->get_billing_first_name(),
    383                 'billing_last_name'    => $order->get_billing_last_name(),
    384                 'billing_company'      => $order->get_billing_company(),
    385                 'billing_address_1'    => $order->get_billing_address_1(),
    386                 'billing_address_2'    => $order->get_billing_address_2(),
    387                 'billing_city'         => $order->get_billing_city(),
    388                 'billing_state'        => $order->get_billing_state(),
    389                 'billing_postcode'     => $order->get_billing_postcode(),
    390                 'billing_country'      => $order->get_billing_country(),
    391                 'billing_email'        => $order->get_billing_email(),
    392                 'billing_phone'        => $order->get_billing_phone(),
    393                 'shipping_first_name'  => $order->get_shipping_first_name(),
    394                 'shipping_last_name'   => $order->get_shipping_last_name(),
    395                 'shipping_company'     => $order->get_shipping_company(),
    396                 'shipping_address_1'   => $order->get_shipping_address_1(),
    397                 'shipping_address_2'   => $order->get_shipping_address_2(),
    398                 'shipping_city'        => $order->get_shipping_city(),
    399                 'shipping_state'       => $order->get_shipping_state(),
    400                 'shipping_postcode'    => $order->get_shipping_postcode(),
    401                 'shipping_country'     => $order->get_shipping_country(),
    402                 'shipping_phone'       => $order->get_shipping_phone(),
    403                 'payment_method'       => $order->get_payment_method(),
     377                'status' => $order->get_status(),
     378                'currency' => $order->get_currency(),
     379                'shipping_tax' => $order->get_shipping_tax(),
     380                'total' => $order->get_total(),
     381                'total_tax' => $order->get_total_tax(),
     382                'order_key' => $order->get_order_key(),
     383                'billing_first_name' => $order->get_billing_first_name(),
     384                'billing_last_name' => $order->get_billing_last_name(),
     385                'billing_company' => $order->get_billing_company(),
     386                'billing_address_1' => $order->get_billing_address_1(),
     387                'billing_address_2' => $order->get_billing_address_2(),
     388                'billing_city' => $order->get_billing_city(),
     389                'billing_state' => $order->get_billing_state(),
     390                'billing_postcode' => $order->get_billing_postcode(),
     391                'billing_country' => $order->get_billing_country(),
     392                'billing_email' => $order->get_billing_email(),
     393                'billing_phone' => $order->get_billing_phone(),
     394                'shipping_first_name' => $order->get_shipping_first_name(),
     395                'shipping_last_name' => $order->get_shipping_last_name(),
     396                'shipping_company' => $order->get_shipping_company(),
     397                'shipping_address_1' => $order->get_shipping_address_1(),
     398                'shipping_address_2' => $order->get_shipping_address_2(),
     399                'shipping_city' => $order->get_shipping_city(),
     400                'shipping_state' => $order->get_shipping_state(),
     401                'shipping_postcode' => $order->get_shipping_postcode(),
     402                'shipping_country' => $order->get_shipping_country(),
     403                'shipping_phone' => $order->get_shipping_phone(),
     404                'payment_method' => $order->get_payment_method(),
    404405                'payment_method_title' => $order->get_payment_method_title(),
    405                 'transaction_id'       => $order->get_transaction_id(),
    406                 'date_paid'            => $order->get_date_paid(),
     406                'transaction_id' => $order->get_transaction_id(),
     407                'date_paid' => $order->get_date_paid(),
    407408            ];
    408409        }
     
    411412    }
    412413}
     414
    413415
    414416if (!function_exists('buildecom_wc_order_status_changed')) {
     
    422424
    423425        if ($newStatus === 'pending') {
    424             buildecom_notify($user, 'WC_PENDING', $shortCodesArr, ['push']);
     426            buildecom_notify($user, 'WC_PENDING', $shortCodesArr, ['email']);
    425427        } else if ($newStatus === 'processing') {
    426             buildecom_notify($user, 'WC_PROCESSING', $shortCodesArr, ['push']);
     428            buildecom_notify($user, 'WC_PROCESSING', $shortCodesArr, ['email']);
    427429        } else if ($newStatus === 'shipped') {
    428             buildecom_notify($user, 'WC_SHIPPED', $shortCodesArr, ['push']);
     430            buildecom_notify($user, 'WC_SHIPPED', $shortCodesArr, ['email']);
    429431        } else if ($newStatus === 'on-hold') {
    430             buildecom_notify($user, 'WC_ONHOLD', $shortCodesArr, ['push']);
     432            buildecom_notify($user, 'WC_ONHOLD', $shortCodesArr, ['email']);
    431433        } else if ($newStatus === 'cancelled') {
    432             buildecom_notify($user, 'WC_CANCELLED', $shortCodesArr, ['push']);
     434            buildecom_notify($user, 'WC_CANCELLED', $shortCodesArr, ['email']);
    433435        } else if ($newStatus === 'refunded') {
    434             buildecom_notify($user, 'WC_REFUNDED', $shortCodesArr, ['push']);
     436            buildecom_notify($user, 'WC_REFUNDED', $shortCodesArr, ['email']);
    435437        } else if ($newStatus === 'failed') {
    436             buildecom_notify($user, 'WC_FAILED', $shortCodesArr, ['push']);
     438            buildecom_notify($user, 'WC_FAILED', $shortCodesArr, ['email']);
    437439        } else if ($newStatus === 'completed') {
    438             buildecom_notify($user, 'WC_COMPLETED', $shortCodesArr, ['push']);
     440            buildecom_notify($user, 'WC_COMPLETED', $shortCodesArr, ['email']);
    439441        } else {
    440442            $status = 'WC_' . strtoupper(str_replace('-', '_', $newStatus));
    441             buildecom_notify($user, $status, $shortCodesArr, ['push']);
    442         }
    443     }
    444 }
     443            buildecom_notify($user, $status, $shortCodesArr, ['email']);
     444        }
     445    }
     446}
  • buildecom/trunk/notify/class-buildecom-notify.php

    r3316130 r3344313  
    11<?php
    22
    3 if (!defined('ABSPATH')) exit;
     3if (!defined('ABSPATH'))
     4    exit;
    45
    5 if (!class_exists('Buildecom_Notify_Push')) {
    6     require_once __DIR__ . '/class-buildecom-notify-push.php';
     6if ( ! class_exists( 'Buildecom_Notify_Push' ) ) {
     7    require_once plugin_dir_path(__FILE__) . 'class-buildecom-notify-push.php';
     8}
     9
     10if ( ! class_exists( 'Buildecom_Notify_Email' ) ) {
     11    require_once plugin_dir_path(__FILE__) . 'class-buildecom-notify-email.php';
    712}
    813
     
    97102        //send the notification via methods one by one
    98103        foreach ($methods as $method) {
    99             $notify               = new $method;
     104            $notify = new $method;
    100105            $notify->templateName = $this->templateName;
    101             $notify->shortCodes   = $this->shortCodes;
    102             $notify->user         = $this->user;
    103             $notify->createLog    = $this->createLog;
    104             $notify->userColumn   = $this->userColumn;
     106            $notify->shortCodes = $this->shortCodes;
     107            $notify->user = $this->user;
     108            $notify->createLog = $this->createLog;
     109            $notify->userColumn = $this->userColumn;
    105110            $notify->send();
    106111        }
     
    116121    {
    117122        $methods = [
    118             'push'  => Buildecom_Notify_Push::class
     123            'email' => Buildecom_Notify_Email::class,
     124            'push' => Buildecom_Notify_Push::class
    119125        ];
    120126        if ($sendVia) {
  • buildecom/trunk/notify/class-buildecom-notifyprocess.php

    r3316130 r3344313  
    11<?php
    22
    3 if (!defined('ABSPATH')) exit;
     3if (!defined('ABSPATH'))
     4    exit;
    45
    56class Buildecom_NotifyProcess
     
    145146    protected function getMessage()
    146147    {
     148        global $wpdb;
     149
    147150        $this->prevConfiguration();
    148151
     
    150153        $user = $this->user;
    151154        $globalTemplate = $this->globalTemplate;
    152         //finding the notification template
    153         $template = NotificationTemplate::where('act', $this->templateName)->where($this->statusField, 1)->first();
     155
     156        //finding the notification template (raw DB query instead of NotificationTemplate model)
     157        $table_name = $wpdb->prefix . 'buildecom_notification_templates';
     158        $template = $wpdb->get_row(
     159            $wpdb->prepare(
     160                "SELECT * FROM {$table_name} WHERE act = %s LIMIT 1",
     161                $this->templateName
     162            )
     163        );
    154164        $this->template = $template;
    155165
    156         //Getting the notification message from database if use and template exist
    157         //If not exist, get the message which have sent via method
     166        //Getting the notification message from database if user and template exist
     167        //If not exist, get the message which have been sent via method
    158168        if ($user && $template) {
    159             $message = $this->replaceShortCode($user->fullname, $user->username, get_option($globalTemplate), $template->body);
     169            $message = $this->replaceShortCode(
     170                $user->fullname,
     171                $user->username,
     172                get_option($globalTemplate),
     173                $template->body
     174            );
    160175            if (empty($message)) {
    161176                $message = $template->$body;
    162177            }
    163178        } else {
    164             $message = $this->replaceShortCode($this->receiverName, $this->toAddress, get_option($globalTemplate), $this->message);
    165         }
    166 
    167         //replace the all short cod of template
     179            $message = $this->replaceShortCode(
     180                $this->receiverName,
     181                $this->toAddress,
     182                get_option($globalTemplate),
     183                $this->message
     184            );
     185        }
     186
     187        //replace all shortcodes of template
    168188        if ($this->shortCodes) {
    169189            $message = $this->replaceTemplateShortCode($message);
     
    171191
    172192        //Check email enable
    173         if (!$this->template && $this->templateName) return false;
     193        if (!$this->template && $this->templateName)
     194            return false;
    174195
    175196        //set subject to property
    176197        $this->getSubject();
    177 
    178198
    179199        $this->finalMessage = html_entity_decode(stripslashes($message));
  • buildecom/trunk/readme.txt

    r3344056 r3344313  
    44Requires at least: 4.7
    55Tested up to: 6.8
    6 Stable tag: 1.0.7
     6Stable tag: 1.0.8
    77License: GPL-2.0+
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset for help on using the changeset viewer.