Changeset 3017057
- Timestamp:
- 01/03/2024 02:28:01 PM (2 years ago)
- Location:
- shop-2-api/trunk
- Files:
-
- 3 edited
-
includes/Base/EnqueueWC.php (modified) (5 diffs)
-
readme.txt (modified) (2 diffs)
-
shop-2-api.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
shop-2-api/trunk/includes/Base/EnqueueWC.php
r2982442 r3017057 106 106 107 107 // Display Fields using WooCommerce Action Hook 108 function woocommerce_general_product_data_custom_field( $item)108 function woocommerce_general_product_data_custom_field(): void 109 109 { 110 110 global $post; 111 111 require_once SHOP2API_PLUGIN_PATH . '/includes/Api/Shop2ApiConnect.php'; 112 112 113 $product = wc_get_product( get_the_ID() ); 113 114 $shop_2_api_connection = new Shop2ApiConnect(); 114 115 echo wp_kses('<div class="options_group">', $this->allowed_html); … … 138 139 ); 139 140 140 // Add EAN Number 141 $shop2api_ean_number = get_post_meta( $post->ID, 'shop2api_ean_number', true); 142 woocommerce_wp_text_input( 143 array( 144 'id' => 'shop2api_ean_number', 145 'wrapper_class' => 'cfwc-custom-field', 146 'label' => __('Bol EAN Number', 'woocommerce'), 147 //'description' => __( 'An optional EAN Number that you can map on Shop-2-api or use for orders.', 'woocommerce' ), 148 'value' => $shop2api_ean_number 149 ) 150 ); 151 // Add COMBI EAN Number 152 $shop2api_combi_ean_number = get_post_meta( $post->ID, 'shop2api_combi_ean_number', true); 153 woocommerce_wp_text_input( 154 array( 155 'id' => 'shop2api_combi_ean_number', 156 'wrapper_class' => 'cfwc-custom-field', 157 'label' => __('Combideal EAN Number', 'woocommerce'), 158 //'description' => __( 'An optional EAN Number that you can map on Shop-2-api or use for orders.', 'woocommerce' ), 159 'value' => $shop2api_combi_ean_number 160 ) 161 ); 162 163 $connect_info = $shop_2_api_connection->get_sync_info($post->ID); 164 if (is_wp_error($connect_info)) { 165 echo ''; 166 } elseif (in_array(wp_remote_retrieve_response_code($connect_info), [200, 201])) { 167 $connect_info_data = json_decode(wp_remote_retrieve_body($connect_info), true); 168 if ($connect_info_data && array_key_exists('results', $connect_info_data)) { 169 $results = $connect_info_data['results']; 170 if (count($results) > 0) { 171 echo wp_kses('<p class="form-field">', $this->allowed_html); 172 echo wp_kses('<label>#' . $results[0]['woocommerce_id'] . '</label>', $this->allowed_html); 173 echo wp_kses('<button class="button-primary" data-wc_id="' . $results[0]['woocommerce_id'] . '" id="shop2api-remove-ean">' . __("Remove Offer") . '</button>', $this->allowed_html); 174 echo wp_kses('</p>', $this->allowed_html); 175 176 echo wp_kses('<p class="form-field">', $this->allowed_html); 177 echo wp_kses('<label>Product: </label><b>' . $results[0]['product_last_sync_status'] . ' - ' . $results[0]['product_last_sync_date'] . '</b>', $this->allowed_html); 178 echo wp_kses('</p>', $this->allowed_html); 179 180 echo wp_kses('<p class="form-field">', $this->allowed_html); 181 echo wp_kses('<label>Offer: </label><b>' . $results[0]['offer_last_sync_status'] . ' - ' . $results[0]['offer_last_sync_date'] . '</b>', $this->allowed_html); 182 echo wp_kses('</p>', $this->allowed_html); 183 184 } else { 185 echo wp_kses('<p class="form-field shop2api_sync_to_bol_field">', $this->allowed_html); 186 echo wp_kses('<label>No Sync Data Found</label>', $this->allowed_html); 187 echo wp_kses('<p>', $this->allowed_html); 141 if (!$product->is_type('variable')) { 142 // Add EAN Number 143 $shop2api_ean_number = get_post_meta($post->ID, 'shop2api_ean_number', true); 144 woocommerce_wp_text_input( 145 array( 146 'id' => 'shop2api_ean_number', 147 'wrapper_class' => 'cfwc-custom-field', 148 'label' => __('Bol EAN Number', 'woocommerce'), 149 //'description' => __( 'An optional EAN Number that you can map on Shop-2-api or use for orders.', 'woocommerce' ), 150 'value' => $shop2api_ean_number 151 ) 152 ); 153 // Add COMBI EAN Number 154 $shop2api_combi_ean_number = get_post_meta($post->ID, 'shop2api_combi_ean_number', true); 155 woocommerce_wp_text_input( 156 array( 157 'id' => 'shop2api_combi_ean_number', 158 'wrapper_class' => 'cfwc-custom-field', 159 'label' => __('Combideal EAN Number', 'woocommerce'), 160 //'description' => __( 'An optional EAN Number that you can map on Shop-2-api or use for orders.', 'woocommerce' ), 161 'value' => $shop2api_combi_ean_number 162 ) 163 ); 164 165 $connect_info = $shop_2_api_connection->get_sync_info($post->ID); 166 if (is_wp_error($connect_info)) { 167 echo ''; 168 } elseif (in_array(wp_remote_retrieve_response_code($connect_info), [200, 201])) { 169 $connect_info_data = json_decode(wp_remote_retrieve_body($connect_info), true); 170 if ($connect_info_data && array_key_exists('results', $connect_info_data)) { 171 $results = $connect_info_data['results']; 172 if (count($results) > 0) { 173 echo wp_kses('<p class="form-field">', $this->allowed_html); 174 echo wp_kses('<label>#' . $results[0]['woocommerce_id'] . '</label>', $this->allowed_html); 175 echo wp_kses('<button class="button-primary" data-wc_id="' . $results[0]['woocommerce_id'] . '" id="shop2api-remove-ean">' . __("Remove Offer") . '</button>', $this->allowed_html); 176 echo wp_kses('</p>', $this->allowed_html); 177 178 echo wp_kses('<p class="form-field">', $this->allowed_html); 179 echo wp_kses('<label>Product: </label><b>' . $results[0]['product_last_sync_status'] . ' - ' . $results[0]['product_last_sync_date'] . '</b>', $this->allowed_html); 180 echo wp_kses('</p>', $this->allowed_html); 181 182 echo wp_kses('<p class="form-field">', $this->allowed_html); 183 echo wp_kses('<label>Offer: </label><b>' . $results[0]['offer_last_sync_status'] . ' - ' . $results[0]['offer_last_sync_date'] . '</b>', $this->allowed_html); 184 echo wp_kses('</p>', $this->allowed_html); 185 186 } else { 187 echo wp_kses('<p class="form-field shop2api_sync_to_bol_field">', $this->allowed_html); 188 echo wp_kses('<label>No Sync Data Found</label>', $this->allowed_html); 189 echo wp_kses('<p>', $this->allowed_html); 190 } 188 191 } 189 192 } 193 } else { 194 // Small update to ensure on the main products the EAN is empty. 195 delete_post_meta($post->ID, 'shop2api_ean_number'); 196 delete_post_meta($post->ID, 'shop2api_combi_ean_number'); 190 197 } 191 198 echo wp_kses('</div>', $this->allowed_html); … … 287 294 } 288 295 } 289 290 $shop2api_ean_number = $_POST['shop2api_ean_number'] ?? ''; 291 update_post_meta($post_id, 'shop2api_ean_number', $shop2api_ean_number); 292 293 $shop2api_combi_ean_number = $_POST['shop2api_combi_ean_number'] ?? ''; 294 update_post_meta($post_id, 'shop2api_combi_ean_number', $shop2api_combi_ean_number); 296 if (!$parent_product->is_type('variable')) { 297 $this->set_ean_numbers_per_post($post_id); 298 } 295 299 } 296 300 … … 305 309 update_post_meta($variation_id, 'shop2api_koopblok_service', $woo_checkbox); 306 310 307 $shop2api_ean_number = $_POST['shop2api_ean_number'] ?? ''; 308 update_post_meta($variation_id, 'shop2api_ean_number', $shop2api_ean_number); 309 310 $shop2api_combi_ean_number = $_POST['shop2api_combi_ean_number'] ?? ''; 311 update_post_meta($variation_id, 'shop2api_combi_ean_number', $shop2api_combi_ean_number); 311 $this->set_ean_numbers_per_post($variation_id); 312 312 } 313 313 … … 451 451 } 452 452 } 453 454 /** 455 * @param $post_id 456 * @return void 457 */ 458 private function set_ean_numbers_per_post($post_id): void 459 { 460 $shop2api_ean_number = $_POST['shop2api_ean_number'] ?? ''; 461 if ($shop2api_ean_number == '') { 462 delete_post_meta($post_id, 'shop2api_ean_number'); 463 } else { 464 update_post_meta($post_id, 'shop2api_ean_number', $shop2api_ean_number); 465 } 466 467 $shop2api_combi_ean_number = $_POST['shop2api_combi_ean_number'] ?? ''; 468 if ($shop2api_combi_ean_number == '') { 469 delete_post_meta($post_id, 'shop2api_combi_ean_number'); 470 } else { 471 update_post_meta($post_id, 'shop2api_combi_ean_number', $shop2api_combi_ean_number); 472 } 473 } 453 474 } -
shop-2-api/trunk/readme.txt
r3015222 r3017057 3 3 Plugin URI: https://wordpress.org/plugins/shop-2-api/ 4 4 Tags: WooCommerce, Bol 5 Stable Tag: 1.0.29. 35 Stable Tag: 1.0.29.4 6 6 Requires at least: 5.0 7 7 Requires PHP: 7.2 … … 164 164 1) Reworked Bol.com Product and Offer Mapping 165 165 2) Dropdown Fixes 166 3) Remove Ean number on main product 167 4) Fix issue on empty EAN Number 166 168 167 169 -
shop-2-api/trunk/shop-2-api.php
r3015222 r3017057 5 5 Plugin URI: https://wordpress.org/plugins/shop-2-api/ 6 6 Description: The plugin Shop2Api will sync products between e-Commerce platforms. The current supported e-Commerce platforms are WooCommerce to Bol.com, and we are working on Amazon, Shopify and others. We added a koopblok service so that you can check if you lower your price can you get koopblok. 7 Version: 1.0.29. 37 Version: 1.0.29.4 8 8 Requires at least: 5.0 9 9 Requires PHP: 7.2 … … 34 34 define('SHOP2API_PLUGIN_URL', plugin_dir_url( __FILE__ )); 35 35 define('SHOP2API_PLUGIN', plugin_basename( __FILE__ )); 36 define ('VERSION', '1.0.29. 3');36 define ('VERSION', '1.0.29.4'); 37 37 38 38 // Register items in the project.
Note: See TracChangeset
for help on using the changeset viewer.