Plugin Directory

Changeset 3017057


Ignore:
Timestamp:
01/03/2024 02:28:01 PM (2 years ago)
Author:
ascendedcrow
Message:

Release: 1.0.29.4

Location:
shop-2-api/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • shop-2-api/trunk/includes/Base/EnqueueWC.php

    r2982442 r3017057  
    106106
    107107    // Display Fields using WooCommerce Action Hook
    108     function woocommerce_general_product_data_custom_field($item)
     108    function woocommerce_general_product_data_custom_field(): void
    109109    {
    110110        global $post;
    111111        require_once SHOP2API_PLUGIN_PATH . '/includes/Api/Shop2ApiConnect.php';
    112112
     113        $product = wc_get_product( get_the_ID() );
    113114        $shop_2_api_connection = new Shop2ApiConnect();
    114115        echo wp_kses('<div class="options_group">', $this->allowed_html);
     
    138139        );
    139140
    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                    }
    188191                }
    189192            }
     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');
    190197        }
    191198        echo wp_kses('</div>', $this->allowed_html);
     
    287294            }
    288295        }
    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        }
    295299    }
    296300
     
    305309        update_post_meta($variation_id, 'shop2api_koopblok_service', $woo_checkbox);
    306310
    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);
    312312    }
    313313
     
    451451        }
    452452    }
     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    }
    453474}
  • shop-2-api/trunk/readme.txt

    r3015222 r3017057  
    33Plugin URI: https://wordpress.org/plugins/shop-2-api/
    44Tags: WooCommerce, Bol
    5 Stable Tag: 1.0.29.3
     5Stable Tag: 1.0.29.4
    66Requires at least: 5.0
    77Requires PHP: 7.2
     
    1641641) Reworked Bol.com Product and Offer Mapping
    1651652) Dropdown Fixes
     1663) Remove Ean number on main product
     1674) Fix issue on empty EAN Number
    166168
    167169
  • shop-2-api/trunk/shop-2-api.php

    r3015222 r3017057  
    55Plugin URI: https://wordpress.org/plugins/shop-2-api/
    66Description: 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.3
     7Version: 1.0.29.4
    88Requires at least: 5.0
    99Requires PHP:      7.2
     
    3434define('SHOP2API_PLUGIN_URL', plugin_dir_url( __FILE__ ));
    3535define('SHOP2API_PLUGIN', plugin_basename( __FILE__ ));
    36 define ('VERSION', '1.0.29.3');
     36define ('VERSION', '1.0.29.4');
    3737
    3838// Register items in the project.
Note: See TracChangeset for help on using the changeset viewer.