Changeset 2865279
- Timestamp:
- 02/14/2023 05:52:30 PM (3 years ago)
- Location:
- afterinc-app/trunk
- Files:
-
- 3 edited
-
Custom_app.php (modified) (36 diffs)
-
assets/js/afterinc-customer.js (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
afterinc-app/trunk/Custom_app.php
r2862590 r2865279 4 4 Plugin URI: https://www.afterinc.com/contact/ 5 5 Description: Plugin allows merchants to sell After Plan’s product protection plans for wide variety of products. 6 Version: 3.8. 46 Version: 3.8.5 7 7 Author: After Inc. 8 8 Author URI: https://www.afterinc.com … … 23 23 24 24 private $wpdb, $jal_db_version; 25 const API_BASE_URL = "https://api.quickcover.me/v1/"; 25 26 26 27 public function __construct() { … … 379 380 veriant_id int(20) NOT NULL, 380 381 priceCurrency varchar(255) NOT NULL, 381 planname varchar(255) NOT NULL, 382 pname varchar(255) NOT NULL, 383 description varchar(255) NOT NULL, 382 384 priceCategory varchar(255) NOT NULL, 383 385 termsAndConditionsURL varchar(255) NOT NULL, … … 452 454 } 453 455 456 function get_currency_symbol(){ 457 return get_woocommerce_currency_symbol(); 458 } 459 454 460 function plugin_backup() { 455 461 … … 644 650 $product_json = json_encode($dbData); 645 651 646 $url = 'https://api.quickcover.me/v1/products/outlet/'.$storeId; 652 $base_url = AfterInc::API_BASE_URL; 653 $url = $base_url.'products/outlet/'.$storeId; 647 654 648 655 $args = array( … … 716 723 $storeId = $result[0]->store_id; 717 724 718 $url = 'https://api.quickcover.me/v1/products/outlet/'.$storeId.'?productId='.$product_id; 725 $base_url = AfterInc::API_BASE_URL; 726 $url = $base_url.'products/outlet/'.$storeId.'?productId='.$product_id; 719 727 720 728 $args = array( … … 757 765 $product_json = json_encode($dbData); 758 766 759 $url = 'https://api.quickcover.me/v1/products/outlet/'.$storeId; 767 $base_url = AfterInc::API_BASE_URL; 768 $url = $base_url.'products/outlet/'.$storeId; 760 769 761 770 $args = array( … … 819 828 $product_json = json_encode($dbData); 820 829 821 $url = 'https://api.quickcover.me/v1/products/outlet/'.$storeId; 830 $base_url = AfterInc::API_BASE_URL; 831 $url = $base_url.'products/outlet/'.$storeId; 822 832 823 833 $args = array( … … 887 897 $current_user_id = get_current_user_id(); 888 898 $currency = get_option('woocommerce_currency'); 889 $url = 'https://api.quickcover.me/v1/price/outlet/'.$storeId.'?productId='.$id.'¤cy='.$currency.'&price='.$warrantypric; 899 900 $base_url = AfterInc::API_BASE_URL; 901 $url = $base_url.'price/outlet/'.$storeId.'?productId='.$id.'¤cy='.$currency.'&price='.$warrantypric; 890 902 891 903 $args = array( … … 909 921 $priceCurrency=$warranty_plan->priceCurrency; 910 922 $planName=$warranty_plan->name; 923 $description=$warranty_plan->description; 911 924 $priceCategory=$warranty_plan->priceCategory; 912 925 $termsAndConditionsURL=$warranty_plan->termsAndConditionsURL; … … 937 950 938 951 $results = $this->wpdb->query($this->wpdb->prepare("INSERT INTO product_warranty 939 ( product_id, veriant_id, priceCurrency, p lanname, priceCategory, termsAndConditionsURL, learnMoreURL, plans )940 VALUES ( %d, %d, %s, %s, %s, %s, %s, %s )", $product_id, $veriant_id, $priceCurrency, $planName, $ priceCategory, $termsAndConditionsURL, $learnMoreURL, $plans));952 ( product_id, veriant_id, priceCurrency, pname, description, priceCategory, termsAndConditionsURL, learnMoreURL, plans ) 953 VALUES ( %d, %d, %s, %s, %s, %s, %s, %s )", $product_id, $veriant_id, $priceCurrency, $planName, $description, $priceCategory, $termsAndConditionsURL, $learnMoreURL, $plans)); 941 954 942 955 $warrantyId = $this->wpdb->insert_id; … … 948 961 }else{ 949 962 950 $results = $this->wpdb->query( $this->wpdb->prepare( "UPDATE product_warranty SET veriant_id = %d, priceCurrency = %s, p lanname = %s, priceCategory = %s, termsAndConditionsURL = %s, learnMoreURL = %s, plans = %s WHERE product_id = %d", $veriant_id, $priceCurrency, $planName, $priceCategory, $termsAndConditionsURL, $learnMoreURL, $plans ,$product_id));963 $results = $this->wpdb->query( $this->wpdb->prepare( "UPDATE product_warranty SET veriant_id = %d, priceCurrency = %s, pname = %s, description = %s, priceCategory = %s, termsAndConditionsURL = %s, learnMoreURL = %s, plans = %s WHERE product_id = %d", $veriant_id, $priceCurrency, $planName, $description, $priceCategory, $termsAndConditionsURL, $learnMoreURL, $plans ,$product_id)); 951 964 952 965 } … … 1004 1017 <div class="parent-warranty-class"> 1005 1018 <span class="sortOptions"> 1006 <p class="planheading"><?php echo esc_attr($result[0]-> planname); ?> </p>1019 <p class="planheading"><?php echo esc_attr($result[0]->description); ?> </p> 1007 1020 1008 1021 <input type="hidden" class="warranty-id" value="<?php echo esc_attr($result[0]->id); ?>"> … … 1110 1123 1111 1124 $totalPrice = (float) $productActualPrice + (float) $warrantyPrice; 1112 echo esc_attr($totalPrice);1125 echo json_encode(['totalPrice'=>$totalPrice,'currency_symbol'=>$this->get_currency_symbol()]); 1113 1126 exit(); 1114 1127 … … 1128 1141 1129 1142 $totalPrice1 = (float) $productActualPrice + (float) $warrantyPrice; 1130 $totalPrice= sprintf('%.2f',$totalPrice1); 1131 echo esc_attr($totalPrice); 1143 $totalPrice= sprintf('%.2f',$totalPrice1); 1144 1145 echo json_encode(['totalPrice'=>$totalPrice,'currency_symbol'=>$this->get_currency_symbol()]); 1132 1146 exit(); 1133 1147 } … … 1323 1337 $current_date = sanitize_text_field($_POST['currentTime']); 1324 1338 1325 $url = 'https://api.quickcover.me/v1/authenticate-store/storeId='.$storeid.'/apiKey='.$apikey; 1339 $base_url = AfterInc::API_BASE_URL; 1340 $url = $base_url.'authenticate-store/storeId='.$storeid.'/apiKey='.$apikey; 1326 1341 1327 1342 $body = array( … … 1498 1513 $productJson = json_encode($productLists); 1499 1514 1500 $url = 'https://api.quickcover.me/v1/products/batch/outlet/'.$quick_store_id.'?upsert=true'; 1515 $base_url = AfterInc::API_BASE_URL; 1516 $url = $base_url.'products/batch/outlet/'.$quick_store_id.'?upsert=true'; 1517 1501 1518 $body = array( 1502 1519 'headers' => array( … … 1775 1792 $cancel_contract = json_encode($cancel_contract); 1776 1793 1777 $url = 'https://api.quickcover.me/v1/contracts/outlet/'.$storeId.'/cancel'; 1794 $base_url = AfterInc::API_BASE_URL; 1795 $url = $base_url.'contracts/outlet/'.$storeId.'/cancel'; 1778 1796 1779 1797 $args = array( … … 1804 1822 } 1805 1823 1806 $response = array('status' => 200, 'res' => $refundamt );1824 $response = array('status' => 200, 'res' => $refundamt, 'currency_symbol' => $this->get_currency_symbol()); 1807 1825 echo json_encode($response); 1808 1826 die(); … … 1837 1855 $storeId = $result[0]->store_id; 1838 1856 1839 $url = 'https://api.quickcover.me/v1/products/outlet/'.$storeId.'?productId='.$post_id; 1857 $base_url = AfterInc::API_BASE_URL; 1858 $url = $base_url.'products/outlet/'.$storeId.'?productId='.$post_id; 1840 1859 1841 1860 $args = array( … … 1931 1950 */ 1932 1951 1933 function add_item_meta($item_data, $cart_item)1952 function add_item_meta($item_data, $cart_item) 1934 1953 { 1935 1954 1936 1955 if(array_key_exists('warranty', $cart_item)) 1937 1956 { 1938 // echo "<pre>"; print_r($cart_item); die;1939 1940 $ planname = $this->wpdb->get_results( $this->wpdb->prepare("SELECT * FROM product_warranty"));1957 $product_id = $cart_item['product_id']; 1958 1959 $warrantyData = $this->wpdb->get_results( $this->wpdb->prepare("SELECT * FROM product_warranty WHERE product_id=".$product_id)); 1941 1960 1942 $pname = $ planname[0]->planname;1961 $pname = $warrantyData[0]->pname; 1943 1962 1944 1963 $plan_id = $cart_item['warranty']; … … 1954 1973 $item_data[] = array( 1955 1974 'key' => $pname, 1956 'value' => $term." Months"1975 'value' => "" 1957 1976 ); 1958 1977 1959 }1960 }1978 } 1979 } 1961 1980 return $item_data; 1962 1981 } … … 2095 2114 2096 2115 $orderList = json_encode($order_array); 2097 // print_r($orderList);die;2098 2116 $result = $this->wpdb->get_results( $this->wpdb->prepare( "SELECT * FROM app_configurations WHERE id = %d", 1 )); 2099 2117 … … 2102 2120 $storeId = $result[0]->store_id; 2103 2121 2104 $url = 'https://api.quickcover.me/v1/orders/outlet/'.$storeId; 2122 $base_url = AfterInc::API_BASE_URL; 2123 $url = $base_url.'orders/outlet/'.$storeId; 2105 2124 2106 2125 $args = array( … … 2135 2154 } 2136 2155 } 2137 } else { 2156 } 2157 2158 else { 2138 2159 2139 2160 $dataCron = $this->wpdb->insert('quickcover_cron_status', array( … … 2176 2197 $storeId = $result[0]->store_id; 2177 2198 2178 $url = 'https://api.quickcover.me/v1/contracts/outlet/'.$storeId.'/cancel'; 2199 $base_url = AfterInc::API_BASE_URL; 2200 $url = $base_url.'contracts/outlet/'.$storeId.'/cancel'; 2179 2201 2180 2202 $args = array( … … 2223 2245 } 2224 2246 //contract cancel from customer end. 2225 function woocommerce_order_item_name( $name, $item ){ 2226 2227 $get_configuration_property = $this->wpdb->get_results( $this->wpdb->prepare("SELECT * FROM app_configurations")); 2228 $quickCover_status = $get_configuration_property[0]->configuration_property; 2229 2230 $planname = $this->wpdb->get_results( $this->wpdb->prepare("SELECT * FROM product_warranty")); 2231 $pnamecustomer = $planname[0]->planname; 2232 2247 function woocommerce_order_item_name( $name, $item ){ 2248 2233 2249 $customUrl = esc_url_raw($_SERVER['REQUEST_URI']); 2234 2250 $customUrl = strtolower($customUrl); … … 2243 2259 $product_id = $item['product_id']; 2244 2260 $item_warrantys = $item->get_meta_data(); 2261 2262 $get_configuration_property = $this->wpdb->get_results( $this->wpdb->prepare("SELECT * FROM app_configurations")); 2263 $quickCover_status = $get_configuration_property[0]->configuration_property; 2264 2265 $warrantyData = $this->wpdb->get_results( $this->wpdb->prepare("SELECT * FROM product_warranty WHERE product_id=".$product_id)); 2266 $pnamecustomer = $warrantyData[0]->pname; 2267 2245 2268 foreach ($item_warrantys as $key => $item_warranty) { 2246 2269 if(isset($item_warranty->key) && ($item_warranty->key == '_warranty')){ … … 2254 2277 2255 2278 if(isset($result[0]->contract_status) && $result[0]->contract_status == '200' && $result[0]->refund_amount !=''){ 2256 $refundtxt = "<b>Cancelled By: <b>".$result[0]->contract_canceled_by."<br> Contract has been Cancelled Successfully ,We have initiated the Refund of ";2279 $refundtxt = "<b>Cancelled By: <b>".$result[0]->contract_canceled_by."<br> Contract has been Cancelled Successfully ,We have initiated the Refund of "; 2257 2280 $refundamtqty = $result[0]->refund_amount * $item['quantity']; 2258 2281 $refundamt = number_format((float)$refundamtqty, 2, '.', ''); … … 2263 2286 return $name." ".$term." Months"; 2264 2287 }else{ 2265 return $name." ".$term." Months ".$cancelButton." <br> ".$refundtxt." <b>"."$".$refundamt." </b>";2288 return $name." ".$term." Months ".$cancelButton." <br> <span class='contract-refund-text'>".$refundtxt.$this->get_currency_symbol().$refundamt."</span>"; 2266 2289 } 2267 2290 … … 2278 2301 return $name." ".$term." Months ".$cancelButton." <br> ".$refundtxt; 2279 2302 } 2280 } 2281 2282 else { 2303 2304 } else { 2283 2305 2284 $results = $this->wpdb->get_results( $this->wpdb->prepare( "SELECT * FROM quickcover_contract" ) ); 2285 $order_id = array(); 2286 2287 foreach ($results as $key => $value) { 2288 $order_id[] = $value->order_id; 2289 } 2290 $orderIDs = array_unique($order_id); 2306 $results = $this->wpdb->get_results( $this->wpdb->prepare( "SELECT * FROM quickcover_contract WHERE order_id=".$productOrderId) ); 2291 2307 2292 if ( in_array($productOrderId, $orderIDs)){2293 $cancelButton = "<button class='cancelContract' id=".$item_quantity." style='display: block; padding: 5px 10px; font-size: 13px; border: none; background: #009688; font-family: sans-serif; float: right; margin-right: 3 20px' data-orderId=".$productOrderId." data-lineItemID=".$lineItemId." data-cancelby='customer'> Cancel ".$pnamecustomer."</button>";2308 if (!empty($results)){ 2309 $cancelButton = "<button class='cancelContract' id=".$item_quantity." style='display: block; padding: 5px 10px; font-size: 13px; border: none; background: #009688; font-family: sans-serif; float: right; margin-right: 30%' data-orderId=".$productOrderId." data-lineItemID=".$lineItemId." data-cancelby='customer'> Cancel ".$pnamecustomer."</button>"; 2294 2310 2295 2311 if (($isOrderreceived !== false) && ($isOrderreceived > 0)) { … … 2344 2360 $storeId = $result[0]->store_id; 2345 2361 2346 $url = 'https://api.quickcover.me/v1/contracts/outlet/'.$storeId.'/cancel'; 2362 $base_url = AfterInc::API_BASE_URL; 2363 $url = $base_url.'contracts/outlet/'.$storeId.'/cancel'; 2347 2364 2348 2365 $args = array( … … 2425 2442 /*add button order details page in admin side and cancel order functionality */ 2426 2443 function woocommerce_before_order_itemmeta($item_id, $item, $product){ 2427 2428 $planname = $this->wpdb->get_results( $this->wpdb->prepare("SELECT * FROM product_warranty")); 2429 $pnameadmin = $planname[0]->planname; 2430 2444 2431 2445 $productOrderId = $item['order_id']; 2432 2446 $order = wc_get_order( $productOrderId ); … … 2436 2450 $product_id = $item['product_id']; 2437 2451 $item_warrantys = $item->get_meta_data(); 2452 2453 $warrantyData = $this->wpdb->get_results( $this->wpdb->prepare("SELECT * FROM product_warranty WHERE product_id=".$product_id)); 2454 $pnameadmin = $warrantyData[0]->pname; 2455 2438 2456 foreach ($item_warrantys as $key => $item_warranty) { 2439 2457 if(isset($item_warranty->key) && ($item_warranty->key == '_warranty')){ … … 2457 2475 $refundamtqty = $results[0]->refund_amount * $item['quantity']; 2458 2476 $refundamt = number_format((float)$refundamtqty, 2, '.', ''); 2459 echo '<p><button type="button" class="btn button-primary" data-orderId="'.esc_attr($productOrderId).'" data-lineItemID ="'.esc_attr($lineItemId).'" disabled=true style="cursor: not-allowed;">Cancelled '.esc_attr($pnameadmin).'</button></p><b>Cancelled By : '.esc_attr($results[0]->contract_canceled_by).'<b> <br>Contract has been cancelled successfully,We have initiated the <b>Refund of '. ' $'.esc_attr($refundamt);2477 echo '<p><button type="button" class="btn button-primary" data-orderId="'.esc_attr($productOrderId).'" data-lineItemID ="'.esc_attr($lineItemId).'" disabled=true style="cursor: not-allowed;">Cancelled '.esc_attr($pnameadmin).'</button></p><b>Cancelled By : '.esc_attr($results[0]->contract_canceled_by).'<b> <br>Contract has been cancelled successfully,We have initiated the <b>Refund of '.$this->get_currency_symbol().esc_attr($refundamt); 2460 2478 }else if(isset($results[0]->contract_status) && $results[0]->contract_status == '250' && $results[0]->refund_amount !=''){ 2461 2479 echo '<p><button type="button" class="btn button-primary" data-orderId="'.esc_attr($productOrderId).'" data-lineItemID ="'.esc_attr($lineItemId).'" disabled=true style="cursor: not-allowed;">Cancelled '.esc_attr($pnameadmin).'</button></p><b><br>Cancel Request outside the cancel period,Please contract Administrator'; … … 2791 2809 $storeId = $result[0]->store_id; 2792 2810 2793 $url = 'https://api.quickcover.me/v1/orders/outlet/'.$storeId; 2811 $base_url = AfterInc::API_BASE_URL; 2812 $url = $base_url.'orders/outlet/'.$storeId; 2794 2813 2795 2814 $args = array( -
afterinc-app/trunk/assets/js/afterinc-customer.js
r2859737 r2865279 83 83 var qprice = parseFloat(re.res); 84 84 var total = (parseFloat(qprice*quantity)).toFixed(2); 85 var crnSymbol = parseFloat(re.currency_symbol); 85 86 swal({ 86 87 title: "Success", 87 text: "Contract has been cancelled successfully, We have initiated the refund of $"+total,88 text: "Contract has been cancelled successfully, We have initiated the refund of "+crnSymbol+total, 88 89 icon: "success", 89 90 button: "Ok", … … 153 154 success: function(response) { 154 155 var exist = jQuery('.woocommerce-variation-price .price ins .woocommerce-Price-amount bdi'); 155 var respprice = parseFloat(response).toFixed(2); 156 var arrData = JSON.parse(response); 157 var respprice = parseFloat(arrData.totalPrice).toFixed(2); 158 var crnSymbol = arrData.currency_symbol; 159 156 160 if(exist.length){ 157 jQuery('.woocommerce-variation-price .price ins .woocommerce-Price-amount bdi'). text("$"+respprice);161 jQuery('.woocommerce-variation-price .price ins .woocommerce-Price-amount bdi').html(crnSymbol+respprice); 158 162 }else{ 159 jQuery('.price .woocommerce-Price-amount bdi'). text("$"+respprice);163 jQuery('.price .woocommerce-Price-amount bdi').html(crnSymbol+respprice); 160 164 } 161 165 -
afterinc-app/trunk/readme.txt
r2862590 r2865279 7 7 Requires PHP: 7.2 8 8 WC tested up to: 5.6.0 9 Stable tag: 3.8. 49 Stable tag: 3.8.5 10 10 License: GPLv3 11 11 License URI: https://www.afterinc.com
Note: See TracChangeset
for help on using the changeset viewer.