Plugin Directory

Changeset 2841741


Ignore:
Timestamp:
12/31/2022 07:47:30 AM (3 years ago)
Author:
eberwp
Message:

update new version 2.8 with manual sync, sync logs

Location:
eber
Files:
20 added
3 edited

Legend:

Unmodified
Added
Removed
  • eber/trunk/index.php

    r2341352 r2841741  
    55Description: Eber is a smart member system comes with comprehensive loyalty & rewards system, marketing and analytic tool.
    66Author: Eber
    7 Version: 2.7
     7Version: 2.8
    88Author URI: https://eber.co
    99License: GPLv2 or later
     
    4949    add_action( 'woocommerce_thankyou', array('Eber_Woo','order_action') );
    5050}
     51add_action( 'woocommerce_order_actions', array( 'Eber_Woo', 'customAction' ) );
     52add_action( 'woocommerce_order_action_ns_eber_send', array( 'Eber_Woo', 'order_action_manual' ) );
     53
     54
    5155
    5256// EndWoo
  • eber/trunk/init/eber_woo.php

    r2341352 r2841741  
    2929                $total += $shippingValue;
    3030            }
    31 
    3231
    3332            // call API
     
    9291                         'comment_author_email' => $user->user_email,
    9392                         'comment_author_url' => '',
    94                          'comment_content' => 'Eber Error : '.$result->data['error'],
     93                         'comment_content' => 'Eber Error : '.$result->getErrorString(),
    9594                         'comment_type' => 'order_note',
    9695                         'comment_parent' => 0,
     
    133132            return json_encode($itemData);
    134133        }
     134
     135        public function customAction($actions){
     136            $actions['ns_eber_send'] = __( 'Sync to Eber', 'Eber' );
     137            return $actions;
     138        }
     139
     140        public function order_action_manual($order){
     141            $order_id = $order->ID;
     142            $user = get_userdata($order->user_id);
     143            $total = 0;
     144            $orderData = $order->get_data();
     145            $orderItems = $order->get_items();
     146            foreach($orderItems as $item){
     147                $total += ($item['line_total']);
     148            }
     149            $exclude_tax = get_option('exclude_tax', true);
     150            $exclude_coupon = get_option('exclude_coupon', true);
     151            $exclude_shipping = get_option('exclude_shipping', true);
     152
     153            if(!$exclude_coupon){
     154                $couponValue = isset($orderData['discount_total']) ? $orderData['discount_total'] : 0;
     155                $total += $couponValue;
     156            }
     157
     158            if(!$exclude_tax){
     159                $taxValue = isset($orderData['total_tax']) ? $orderData['total_tax'] : 0;
     160                $total += $taxValue;
     161            }
     162
     163            if(!$exclude_shipping){
     164                $shippingValue = isset($orderData['shipping_total']) ? $orderData['shipping_total'] : 0;
     165                $total += $shippingValue;
     166            }
     167
     168             // call API
     169             require_once(dirname(__FILE__).'/api/API.php');
     170             require_once(dirname(__FILE__).'/api/APIResponse.php');
     171             $api_key = get_option('eber_api_key','');
     172            $api = new API();
     173            $post_data = array();
     174
     175             $post_data['provider'] = 'wordpress';
     176             $post_data['provider_identifier'] = get_option('eber_hash_key','');
     177             $post_data['email'] = isset($user->user_email)?$user->user_email:$order->billing_email;
     178             $post_data['provider_user_id'] = isset($user->ID)?$user->ID:0;
     179             $post_data['display_name'] = $user->display_name;
     180             $post_data['phone'] = $order->billing_phone;
     181             $post_data['phone_code'] = $order->billing_country;
     182             $post_data['hash'] = md5($user->ID.get_option('eber_hash_key',''));
     183             $post_data['transaction_no'] = $order_id;
     184             $post_data['note'] = $order->post->post_password;
     185             $post_data['amount'] = floatval($total);
     186             $post_data['item_data_json'] = Eber_Woo::parseItemJson($orderItems);
     187             if(get_option('adjust_point_when','order_completed') == 'order_completed')
     188             {
     189                if($order->get_status() != 'completed')
     190                {
     191                    $time = current_time('mysql');
     192                    $data = array(
     193                        'comment_post_ID' => $order_id,
     194                        'comment_author' => $user->user_login,
     195                        'comment_author_email' => $user->user_email,
     196                        'comment_author_url' => '',
     197                        'comment_content' => 'Eber Error : Order Status Not Completed to sync',
     198                        'comment_type' => 'order_note',
     199                        'comment_parent' => 0,
     200                        'user_id' => $user->ID,
     201                        'comment_author_IP' => '',
     202                        'comment_agent' => 'Eber',
     203                        'comment_date' => $time,
     204                        'comment_approved' => 1,
     205                    );
     206                    wp_insert_comment($data);
     207                    return false;
     208                }
     209             }
     210             if(!get_option('eber_sync_non_member',false) && !$order->get_user())
     211             {
     212                 
     213             }
     214             else
     215             {
     216                $result = $api->setData($post_data)
     217                     ->setQueue()
     218                     ->requireAuth($api_key)
     219                     ->post('/v5/point/ecom');
     220                 
     221                     if (!$result->isFailure())
     222                     {
     223                         $return_api = $result->data;
     224                         $time = current_time('mysql');
     225   
     226                         $data = array(
     227                             'comment_post_ID' => $order_id,
     228                             'comment_author' => $user->user_login,
     229                             'comment_author_email' => $user->user_email,
     230                             'comment_author_url' => '',
     231                             'comment_content' => 'Eber Success : Added '.$return_api['points'].' Points',
     232                             'comment_type' => 'order_note',
     233                             'comment_parent' => 0,
     234                             'user_id' => $user->ID,
     235                             'comment_author_IP' => '',
     236                             'comment_agent' => 'Eber',
     237                             'comment_date' => $time,
     238                             'comment_approved' => 1,
     239                         );
     240                         wp_insert_comment($data);
     241                     }
     242                     else
     243                     {
     244     
     245                         $time = current_time('mysql');
     246                         $data = array(
     247                             'comment_post_ID' => $order_id,
     248                             'comment_author' => $user->user_login,
     249                             'comment_author_email' => $user->user_email,
     250                             'comment_author_url' => '',
     251                             'comment_content' => 'Eber Error : '.$result->getErrorString(),
     252                             'comment_type' => 'order_note',
     253                             'comment_parent' => 0,
     254                             'user_id' => $user->ID,
     255                             'comment_author_IP' => '',
     256                             'comment_agent' => 'Eber',
     257                             'comment_date' => $time,
     258                             'comment_approved' => 1,
     259                         );
     260                         wp_insert_comment($data);
     261                     }
     262             }
     263           
     264
     265        }
    135266    }
    136267?>
  • eber/trunk/readme.txt

    r2424136 r2841741  
    44Tags: Membership, Business, Member Card, Loyalty, Reward, Points system
    55Requires at least: 4.2
    6 Tested up to: 5.6
    7 Stable tag: 5.1
     6Tested up to: 6.1
     7Stable tag: 6.1
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    7979= 2.7 =
    8080Fix multi language in line item sync
     81= 2.8 =
     82Update Manual sync button and Sync Logs
    8183== Upgrade Notice ==
    8284= 0.1 =
     
    119121= 2.7 =
    120122Fix multi language in line item sync
     123= 2.8 =
     124Update Manual sync button and Sync Logs
    121125
    122126
     
    125129
    126130
    127 
Note: See TracChangeset for help on using the changeset viewer.