Changeset 3148549
- Timestamp:
- 09/09/2024 09:43:14 AM (19 months ago)
- Location:
- hfd-epost-integration/trunk
- Files:
-
- 5 edited
-
class/App.php (modified) (1 diff)
-
class/Cart/Pickup.php (modified) (5 diffs)
-
class/Helper/Hfd/Api.php (modified) (2 diffs)
-
hfd-woocommerce-epost.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
hfd-epost-integration/trunk/class/App.php
r3137242 r3148549 80 80 81 81 //action for gutenberg 82 if( function_exists( 'use_block_editor_for_post' ) && use_block_editor_for_post( get_option( 'woocommerce_checkout_page_id' )) && !is_admin() ){82 if( $this->is_block_checkout() && !is_admin() ){ 83 83 add_action( 'woocommerce_after_order_object_save', array( $this, 'hfd_save_pickup_info_block' ), 11, 2 ); 84 add_action( 'wp_ajax_hfd_get_additional_data', array( $this, 'hfdRenderAdditionalData') );85 add_action( 'wp_ajax_nopriv_hfd_get_additional_data', array( $this, 'hfdRenderAdditionalData' ) );86 84 }else{ 87 85 add_action( 'woocommerce_checkout_order_processed', array( $this, 'convertPickupToOrder'), 10, 3 ); 88 86 add_action( 'woocommerce_new_order', array($this, 'convertPickupToOrderOptional'), 99, 2 ); 89 87 } 90 } 88 89 //action for render data 90 add_action( 'wp_ajax_hfd_get_additional_data', array( $this, 'hfdRenderAdditionalData' ) ); 91 add_action( 'wp_ajax_nopriv_hfd_get_additional_data', array( $this, 'hfdRenderAdditionalData' ) ); 92 } 93 94 public function is_block_checkout(){ 95 $checkout_page_id = get_option( 'woocommerce_checkout_page_id' ); 96 if( $checkout_page_id ){ 97 //Get post object 98 $post = get_post( $checkout_page_id ); 99 100 //Check if Gutenberg (block editor) is enabled for checkout 101 return $post && post_type_supports( $post->post_type, 'editor' ); 102 } 103 return false; 104 } 91 105 92 106 public function hfdUpdatePluginsOptions(){ -
hfd-epost-integration/trunk/class/Cart/Pickup.php
r2766592 r3148549 14 14 public function saveSpotInfo($spotInfo) 15 15 { 16 $session = WC()->session; 17 $session->set('epost_spot_info', $spotInfo); 16 if( isset( WC()->session ) ){ 17 $session = WC()->session; 18 $session->set( 'epost_spot_info', $spotInfo ); 19 } 18 20 } 19 21 … … 23 25 public function getSpotInfo() 24 26 { 25 $spotInfo = WC()->session->get('epost_spot_info'); 27 if( isset( WC()->session ) ){ 28 $spotInfo = WC()->session->get('epost_spot_info'); 26 29 27 if (!$spotInfo || !is_array($spotInfo)) {28 return null;29 }30 if (!$spotInfo || !is_array($spotInfo)) { 31 return null; 32 } 30 33 31 return array_map(function ($value) { 32 return stripslashes($value); 33 }, $spotInfo); 34 return array_map(function ($value) { 35 return stripslashes($value); 36 }, $spotInfo); 37 } 38 return; 34 39 } 35 40 … … 39 44 public function clearSpotInfo() 40 45 { 41 WC()->session->set('epost_spot_info', null); 46 if( isset( WC()->session ) ){ 47 WC()->session->set( 'epost_spot_info', null ); 48 } 49 return; 42 50 } 43 51 … … 49 57 $shippingItems = $order->get_shipping_methods(); 50 58 51 if (!count($shippingItems)){59 if( !count( $shippingItems ) ){ 52 60 return; 53 61 } 54 62 55 63 /* @var \WC_Order_Item_Shipping $shippingItem */ 56 foreach ($shippingItems as $shippingItem){64 foreach( $shippingItems as $shippingItem ){ 57 65 $shippingItem->get_formatted_meta_data(); 58 66 $methodId = \Hfd\Woocommerce\Shipping\Epost::METHOD_ID; 59 if (substr($shippingItem->get_method_id(), 0, strlen($methodId)) == $methodId){67 if( substr( $shippingItem->get_method_id(), 0, strlen( $methodId ) ) == $methodId ){ 60 68 $spotInfo = $this->getSpotInfo(); 61 if ($spotInfo){69 if( $spotInfo ){ 62 70 // add pickup info into shipping item 63 71 $spotInfo = serialize($spotInfo); … … 67 75 } 68 76 } 69 70 $this->clearSpotInfo(); 77 78 //check if session set 79 if( isset( WC()->session ) ){ 80 $this->clearSpotInfo(); 81 } 71 82 } 72 83 } -
hfd-epost-integration/trunk/class/Helper/Hfd/Api.php
r3097702 r3148549 99 99 $pParam = apply_filters( 'hfd_before_sync', $pParam ); 100 100 101 $url = 'https:// ws.hfd.co.il/RunCom.WebAPI/api/v1/shipments/create';101 $url = 'https://api.hfd.co.il/rest/v2/shipments/create'; 102 102 103 103 $result = array( … … 296 296 return $order->get_total(); 297 297 } 298 return '';298 return 0; 299 299 } 300 300 -
hfd-epost-integration/trunk/hfd-woocommerce-epost.php
r3137242 r3148549 5 5 Plugin URI: 6 6 Description: Add shipping method of ePost, allowing the user on the checkout, to select the pickup location point from a google map popup. Also allows to synch the order to HFD API after the order is created. 7 Version: 2. 87 Version: 2.9 8 8 Author: HFD 9 9 Author URI: https://www.hfd.co.il -
hfd-epost-integration/trunk/readme.txt
r3137242 r3148549 5 5 Requires at least: 4.0 6 6 Tested up to: 6.6 7 Stable tag: 2. 87 Stable tag: 2.9 8 8 Requires PHP: 5.4 9 9 License: GPLv2 or later … … 101 101 * Performance Improvement 102 102 103 = 2.9 = 104 * Performance Improvement 105 103 106 == Frequently Asked Questions == 104 107 = Why Google Maps isnt loading = 105 108 Need to add Google map API key 106 Need to creat Google Maps Key following the orders109 Need to create Google Maps Key following the orders 107 110 108 111 = Where I can find my Customer number =
Note: See TracChangeset
for help on using the changeset viewer.