Changeset 2850169
- Timestamp:
- 01/18/2023 02:34:55 AM (3 years ago)
- Location:
- app360/trunk
- Files:
-
- 3 edited
-
app360.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
voucher.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
app360/trunk/app360.php
r2849502 r2850169 11 11 * Plugin URI: https://www.app360.my/ 12 12 * Description: App360 CRM allows the integration between WooCommerce and App360 13 * Version: 1.3.1 113 * Version: 1.3.12 14 14 * Author: App360 15 15 * License: GPLv2 or later -
app360/trunk/readme.txt
r2849502 r2850169 4 4 Requires at least: 5.6 5 5 Tested up to: 5.8 6 Stable tag: 1.3.1 16 Stable tag: 1.3.12 7 7 License: GPLv2 or later 8 8 … … 39 39 == Changelog == 40 40 41 = 1.3.12 = 42 *Release Date - 17 January 2023* 43 44 * bugfix | Fix incorrect method to get user_id in coupon validity check function 45 41 46 = 1.3.11 = 42 47 *Release Date - 16 January 2023* -
app360/trunk/voucher.php
r2849502 r2850169 75 75 $code = get_post($coupon->get_id())->post_title; 76 76 if(!in_array($code, $applied_coupons)){ 77 $user_id = get_current_user_id(); 78 $user_id = get_user_meta($user_id, 'app360_userid') ? get_user_meta($user_id, 'app360_userid')[0] : 0; 79 $reward_id = get_post_meta($coupon->get_id(), 'voucher_id', true) ? get_post_meta($coupon->get_id(), 'voucher_id', true) : 0; 80 //$tier = get_post_meta($coupon->get_id(), 'app360_tier', true) ? get_post_meta($coupon->get_id(), 'app360_tier', true) : 0; 81 //$tier_id = get_post_meta($coupon->get_id(), 'app360_tier_id', true) ? get_post_meta($coupon->get_id(), 'app360_tier_id', true) : 0; 82 83 if($reward_id && $reward_id != 0){ 84 $url = $app360_api_domain.'/client/voucher/apply?'; 85 $url .= 'user_id='.$user_id; 86 $url .= '&reward_id='.$reward_id; 87 $headers = array(); 88 $headers['Content-type'] = 'application/json'; 89 $headers['apikey'] = $app360_api; 90 $response = wp_remote_get($url, ['headers'=> $headers]); 91 92 $result = is_array($response) && isset($response['body']) ? json_decode($response['body']) : null; 93 if( !$result || !$result->available){ 94 throw new Exception( __( 'You do not have this coupon.', 'woocommerce' ), 107 ); 95 } 96 WC()->session->set( 'voucher_id', $result->voucher_id ); 97 } 77 $users = array(); 78 $coupon_data = $coupon->get_data(); 79 if($coupon_data) { 80 $users = $coupon_data['used_by']; 81 } 82 if (!$users) { 83 throw new Exception( __( 'Voucher Apply Error: Unable get any user data from coupon usage!.', 'woocommerce' ), 107 ); 84 } 85 86 foreach ($users as $wc_user_id) { 87 $user_id = get_user_meta($wc_user_id, 'app360_userid') ? get_user_meta($wc_user_id, 'app360_userid')[0] : 0; 88 $reward_id = get_post_meta($coupon->get_id(), 'voucher_id', true) ? get_post_meta($coupon->get_id(), 'voucher_id', true) : 0; 89 //$tier = get_post_meta($coupon->get_id(), 'app360_tier', true) ? get_post_meta($coupon->get_id(), 'app360_tier', true) : 0; 90 //$tier_id = get_post_meta($coupon->get_id(), 'app360_tier_id', true) ? get_post_meta($coupon->get_id(), 'app360_tier_id', true) : 0; 91 92 if($reward_id && $reward_id != 0){ 93 $url = $app360_api_domain.'/client/voucher/apply?'; 94 $url .= 'user_id='.$user_id; 95 $url .= '&reward_id='.$reward_id; 96 $headers = array(); 97 $headers['Content-type'] = 'application/json'; 98 $headers['apikey'] = $app360_api; 99 $response = wp_remote_get($url, ['headers'=> $headers]); 100 101 $result = is_array($response) && isset($response['body']) ? json_decode($response['body']) : null; 102 if( !$result || !$result->available){ 103 throw new Exception( __( 'You do not have this coupon.', 'woocommerce' ), 107 ); 104 } 105 WC()->session->set( 'voucher_id', $result->voucher_id ); 106 } 107 } 98 108 } 99 109
Note: See TracChangeset
for help on using the changeset viewer.