Changeset 2849244
- Timestamp:
- 01/16/2023 03:13:15 PM (3 years ago)
- Location:
- extendago-wp-connection/trunk
- Files:
-
- 5 edited
-
extendago-wp-connection.php (modified) (1 diff)
-
includes/admin/class-extendago-wp-connection-admin.php (modified) (1 diff)
-
includes/cronjob/class-extendago-cronjob-functions.php (modified) (7 diffs)
-
includes/woocommerce/class-extendago-woocommerce-functions.php (modified) (12 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
extendago-wp-connection/trunk/extendago-wp-connection.php
r2839827 r2849244 4 4 Plugin URI: http://www.arture.nl/extendago 5 5 Description: The Wordpress plugin for connecting Woocommerce with Extendago / Wallmob. Manage your products inside Extendago and let our connection do the magic. 6 Version: 1.2. 66 Version: 1.2.7 7 7 Author: Arture B.V. 8 8 Author URI: https://arture.nl/ -
extendago-wp-connection/trunk/includes/admin/class-extendago-wp-connection-admin.php
r2826526 r2849244 96 96 register_setting('extendago_api_options', 'extendago_api_arture_key'); 97 97 98 // Iterate Woocommerce shipping methods99 98 if ( class_exists( 'WooCommerce' ) ) { 100 101 99 $Extendago = new Extendago_Web_Api(); 102 100 $VatRates = $Extendago->CurlRequest("/vat_rates", "GET"); -
extendago-wp-connection/trunk/includes/cronjob/class-extendago-cronjob-functions.php
r2839827 r2849244 108 108 if( !isset($_POST['product_id']) ) $this->logging->log_file_write( 'GetAllWebshopProducts | ' .count($products) ); 109 109 110 if( isset($_POST[' sc_product_id']) && !empty($_POST['sc_product_id']) ) {111 $this->logging->log_file_write( 'Manual | Manual triggered synchronisation for product: ' .$_POST[' sc_product_id']);110 if( isset($_POST['product_id']) && !empty($_POST['product_id']) ) { 111 $this->logging->log_file_write( 'Manual | Manual triggered synchronisation for product: ' .$_POST['product_id']); 112 112 } 113 113 … … 641 641 642 642 // Process featured image 643 $ExtendagoProductJSON['image'] = ''; 643 644 if (isset($product['image']) && !empty($product['image'])){ 644 645 $image = new \CurlFile($product['image'], mime_content_type($product['image']), time().'_'.basename($product['image'])); … … 659 660 'product_id' => $product['id'], 660 661 'price_region_id' => $price_region_id, 661 'vat_rate_id' => null,662 'vat_rate_id' => $product['vat_rate_id'], 662 663 'least_quantity' => null, 663 664 'weekcover' => 0, … … 681 682 $unit_id = 'pc'; 682 683 } 684 683 685 684 686 // First variation … … 692 694 'product_id' => $product['id'], 693 695 'price_region_id' => $price_region_id, 694 'vat_rate_id' => null,696 'vat_rate_id' => $variation->vat_rate_id, 695 697 'least_quantity' => null, 696 698 'weekcover' => 0, … … 714 716 'product_variant_id' => $variation->id, 715 717 'price_region_id' => $price_region_id, 716 'vat_rate_id' => null,718 'vat_rate_id' => $variation->vat_rate_id, 717 719 'least_quantity' => null, 718 720 'weekcover' => 0, … … 1273 1275 foreach ( $stock_change['stock_event_lines'] as $stock_event_line ) { 1274 1276 1277 if( $stock_event_line['stock_event_lines']['name'] == 'CountStock of product' ){ 1278 continue; 1279 } 1280 1275 1281 $total_sychronized_stock_changes++; 1276 1282 1277 $this->logging->log_file_write('ExtendaGo | ' . strtok($stock_change['reference_id'], ' -') . ' of product: ' . $stock_event_line[' name']);1283 $this->logging->log_file_write('ExtendaGo | ' . strtok($stock_change['reference_id'], ' -') . ' of product: ' . $stock_event_line['stock_event_lines']['name']); 1278 1284 1279 1285 // Save new product stock values -
extendago-wp-connection/trunk/includes/woocommerce/class-extendago-woocommerce-functions.php
r2839827 r2849244 9 9 add_action( 'woocommerce_update_product', array($this, 'save_product_as_export_batch'), 10, 1 ); 10 10 add_action( 'wp_trash_post', array($this, 'after_wp_trash_post')); 11 add_action( 'untrash_post', array($this, 'save_product_as_export_batch')); 11 12 12 13 add_filter( 'woocommerce_product_data_tabs', array($this, 'add_extendago_product_data_tab') ); … … 46 47 if($post->post_type === 'product') { 47 48 48 // $extendago_product_id = get_post_meta( $post_id, 'extendago_product_id', true ); 49 // 50 // //require_once(__DIR__ . "/../api/class-extendago-web-api.php"); 51 // $Extendago = new Extendago_Web_Api(); 52 // $ProductResponse = $Extendago->CurlRequest('/products/'.$extendago_product_id, 'GET'); 53 // 54 // echo '<pre>'; 55 // print_r($ProductResponse); 56 // echo '</pre>'; 57 // if( isset($ProductResponse['id']) ){ 58 // $ExtendagoProductJSON = array( 59 // 'id' => $extendago_product_id, 60 // 'attributes' => array( 61 // 'hide_from_web' => '1' 62 // ) 63 // ); 64 // 65 // $test = $Extendago->CurlRequest('/products/'.$extendago_product_id, 'PUT', $ExtendagoProductJSON, false, true); 66 // 67 // echo '<pre>'; 68 // print_r($test); 69 // echo '</pre>'; 70 // } 71 // 72 // exit; 73 49 $extendago_product_id = get_post_meta( $post_id, 'extendago_product_id', true ); 50 51 require_once(__DIR__ . "/../api/class-extendago-web-api.php"); 52 $Extendago = new Extendago_Web_Api(); 53 $ProductResponse = $Extendago->CurlRequest('/products/'.$extendago_product_id, 'GET'); 54 55 if( isset($ProductResponse['id']) ){ 56 $Extendago->CurlRequest('/products/'.$extendago_product_id, 'DELETE', array(), false, true); 57 } 74 58 } 75 59 … … 125 109 } 126 110 127 function save_product_as_export_batch( $product_id ) { 111 function save_product_as_export_batch( $product_id ) 112 { 113 114 $post = get_post($product_id); 115 116 if ($post->post_type !== 'product') { 117 return; 118 } 128 119 129 120 $extendago_export_only = get_option('extendago_export_only'); 130 if ( !isset($extendago_export_only) || $extendago_export_only == '0' || $extendago_export_only == '') {121 if (!isset($extendago_export_only) || $extendago_export_only == '0' || $extendago_export_only == '') { 131 122 return; 132 123 } 133 124 134 $product = wc_get_product( $product_id);125 $product = wc_get_product($product_id); 135 126 136 127 // Upload directory … … 138 129 $upload_dir = $upload['basedir']; 139 130 $new_upload_dir = $upload_dir . '/extendago/exports'; 131 132 $Extendago = new Extendago_Web_Api(); 133 $VatRates = $Extendago->CurlRequest("/vat_rates", "GET"); 134 $vat_rate_id = ''; 135 foreach ($VatRates as $VatRate){ 136 $value = get_option($VatRate['id']); 137 if( $value == $product->get_tax_class() ){ 138 $vat_rate_id = $VatRate['id']; 139 break; 140 } 141 } 140 142 141 143 $product_data = array(); … … 149 151 $product_data['short_description'] = $product->get_short_description(); 150 152 $product_data['sku'] = $product->get_sku(); 153 $product_data['vat_rate_id'] = $vat_rate_id; 151 154 152 155 // Get Product Prices … … 156 159 157 160 $product_attributes = $product->get_attributes(); 158 if ( isset($product_attributes) && !empty($product_attributes) ){159 foreach ( $product_attributes as $product_attribute_name => $product_attribute ){160 $product_data['attributes'][$product_attribute_name] = $product->get_attribute( $product_attribute_name);161 } 162 } 163 164 if ( $product_data['type'] == 'variable' ){161 if (isset($product_attributes) && !empty($product_attributes)) { 162 foreach ($product_attributes as $product_attribute_name => $product_attribute) { 163 $product_data['attributes'][$product_attribute_name] = $product->get_attribute($product_attribute_name); 164 } 165 } 166 167 if ($product_data['type'] == 'variable') { 165 168 $product_data['variations'] = array(); 166 169 $product_variations = $product->get_children(); 167 if( isset($product_variations) && !empty($product_variations) ){ 168 foreach( $product_variations as $product_variation_id ){ 169 170 $variation_meta = get_post_meta($product_variation_id); 171 foreach( $product_data['attributes'] as $attribute => $attribute_value ){ 172 if( isset($variation_meta['attribute_'.$attribute]) ){ 173 $product_variant_name = $variation_meta['attribute_'.$attribute][0]; 170 if (isset($product_variations) && !empty($product_variations)) { 171 foreach ($product_variations as $product_variation_id) { 172 $Variation = new WC_Product_Variation($product_variation_id); 173 174 $vat_rate_id = $product_data['vat_rate_id']; 175 foreach ($VatRates as $VatRate){ 176 $value = get_option($VatRate['id']); 177 if( $value == $Variation->get_tax_class() ){ 178 $vat_rate_id = $VatRate['id']; 174 179 break; 175 180 } … … 177 182 178 183 $variation_meta = get_post_meta($product_variation_id); 179 foreach( $product_data['attributes'] as $attribute => $attribute_value ){ 180 if( isset($variation_meta['attribute_'.$attribute]) ){ 181 $Variation = new WC_Product_Variation( $product_variation_id ); 184 foreach ($product_data['attributes'] as $attribute => $attribute_value) { 185 if (isset($variation_meta['attribute_' . $attribute])) { 186 $product_variant_name = $variation_meta['attribute_' . $attribute][0]; 187 break; 188 } 189 } 190 191 $variation_meta = get_post_meta($product_variation_id); 192 foreach ($product_data['attributes'] as $attribute => $attribute_value) { 193 if (isset($variation_meta['attribute_' . $attribute])) { 182 194 $attribute_name = $Variation->get_name(); 183 195 $attribute_name = explode(" - ", $attribute_name); … … 187 199 } 188 200 189 if ( isset($product_variant_name)) {201 if (isset($product_variant_name)) { 190 202 $product_data['variations'][] = array( 191 203 'id' => $product_variation_id, … … 196 208 'retail_price' => $variation_meta['_price'][0], 197 209 'sale_price' => $variation_meta['_sale_price'][0], 210 'vat_rate_id' => $vat_rate_id, 198 211 ); 199 212 } … … 201 214 } 202 215 203 } 204 else{ 216 } else { 205 217 $product_data['quantity'] = $product->get_stock_quantity(); 206 218 $product_data['status'] = $product->get_stock_status(); … … 208 220 209 221 $product_categories = wp_get_object_terms($product_data['id'], 'product_cat'); 210 if ( isset($product_categories) && !empty($product_categories) ){211 foreach ( $product_categories as $product_category ){222 if (isset($product_categories) && !empty($product_categories)) { 223 foreach ($product_categories as $product_category) { 212 224 $product_data['categories'][$product_category->term_id] = array( 213 225 'name' => $product_category->name, … … 221 233 // Get Product Images 222 234 $thumbnail_id = $product->get_image_id(); 223 if ( isset($thumbnail_id) && !empty($thumbnail_id) ){235 if (isset($thumbnail_id) && !empty($thumbnail_id)) { 224 236 $product_data['image'] = get_attached_file($thumbnail_id, true); 225 237 } 226 238 $gallery_image_ids = $product->get_gallery_image_ids(); 227 if ( isset($gallery_image_ids) && !empty($gallery_image_ids) ){228 foreach ( $gallery_image_ids as $gallery_image_id ){239 if (isset($gallery_image_ids) && !empty($gallery_image_ids)) { 240 foreach ($gallery_image_ids as $gallery_image_id) { 229 241 $product_data['gallery'][] = get_attached_file($gallery_image_id, true); 230 242 } -
extendago-wp-connection/trunk/readme.txt
r2839827 r2849244 5 5 Requires at least: 6.0 6 6 Tested up to: 6.1.1 7 Stable tag: 1.2. 67 Stable tag: 1.2.7 8 8 Requires PHP: 7.4 9 9 License: GPLv2 or later … … 30 30 31 31 == Changelog == 32 33 = 1.2.7 = 34 * Vat rate processing for exports 35 * Performance updates 36 * Image delete action 37 * Product delete action 32 38 33 39 = 1.2.6 =
Note: See TracChangeset
for help on using the changeset viewer.