Plugin Directory

Changeset 3007787


Ignore:
Timestamp:
12/10/2023 01:49:39 PM (2 years ago)
Author:
ascendedcrow
Message:

1.0.29.0
Reworked Bol.com Product and Offer Mapping

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

Legend:

Unmodified
Added
Removed
  • shop-2-api/trunk/assets/bol2api_category_mapping_scripts.js

    r2982472 r3007787  
    11(function ($) {
    2     let saved_bol_category_data = {};
    3 
    42    $(document).ready(function () {
    53        // Get all the categories and if there is any saved populate saved_bol_category_data
    64        set_wc_category_field_dropdown();
    7         get_bol_wc_mapping_info();
    8         // Add click and change events
    9         $('tr').on('click', 'td select', handle_wc_cat_click).on('change', 'td select', handle_bol_cat_change);
    10         $('tr').on('click', 'td input', handle_bol_txt_change).on('change', 'td input', handle_bol_txt_change);
     5        // Save Data
     6        $('#category-save').on('click', set_bol_wc_mapping_info);
     7    });
    118
    12         // Save Data
    13         $('#category-save').on('click', handle_cat_save);
    14     });
    15     //Save Button Handler
    16     function handle_cat_save(e) {
    17         e.preventDefault();
    18         set_bol_wc_mapping_info();
     9    function get_table_data() {
     10        let tableData = [];
     11        $("#the-list tr").each(function() {
     12            let rowData = {};
     13            $(this).find('input, select').each(function() {
     14                if ($(this).is(":checkbox")) {
     15                    rowData[this.name] = $(this).is(":checked");
     16                } else {
     17                    rowData[this.name] = $(this).val();
     18                }
     19                $.extend(rowData, $(this).data());
     20            });
     21            tableData.push(rowData);
     22
     23        });
     24
     25        return tableData;
    1926    }
    2027
    21     // Assign old value to dropdown on click
    22     function handle_wc_cat_click() {
    23         $(this).attr("data-old_value", $(this).val());
    24         return $(this);
    25     }
    26 
    27     function handle_bol_txt_change() {
    28         update_cost_values(this);
    29     }
    30 
    31     // Handle Bol Category change
    32     function handle_bol_cat_change() {
    33         $(this).attr("data-old_value", $(this).val());
    34         update_saved_bol_category_data(this);
    35     }
    36 
    37     // If a different option is selected (select to metadata/categories)
    38     function handle_cat_change() {
    39         set_bol_wc_mapping_info(true);
    40     }
    4128
    4229    // This will set the Top dropdown with the data from woocommerce_option_data
    4330    function set_wc_category_field_dropdown() {
    4431        let data_container = $('span[name="wc-data-container"]');
     32        let categories = {
     33            "categories": "All Categories",
     34            "main_categories": "Main Categories",
     35            "tags": "Tags",
     36            "meta_data": "Metadata",
     37            "attributes": "Attributes",
     38
     39        }
    4540        data_container.children().remove();
    4641
     
    5146            value: "", text: "-- select an option --", hidden: "hidden", disabled: "disabled", selected: "selected"
    5247        }).appendTo(_select);
    53 
    54         // Added Tags/Metadata options
    55         $('<option />', {value: "categories", text: "All Categories"}).appendTo(_select);
    56         $('<option />', {value: "main_categories", text: "Main Categories"}).appendTo(_select);
    57         $('<option />', {value: "tags", text: "Tags"}).appendTo(_select);
    58         $('<option />', {value: "meta_data", text: "Metadata"}).appendTo(_select);
    59         $('<option />', {value: "attributes", text: "Attributes"}).appendTo(_select);
    60 
    61         _select.change(handle_cat_change)
     48        let map_category = settings.map_category
     49        for (let category in categories) {
     50            let option_data = {
     51                value: category,
     52                text: categories[category]
     53            }
     54            if (category === map_category) {
     55                option_data["selected"] = "selected";
     56            }
     57            $('<option />', option_data).appendTo(_select);
     58        }
     59        _select.change(set_bol_wc_mapping_info);
    6260        _select.appendTo(data_container);
    6361    }
    6462
    65     // Get the saved mapping data from bol (Shoes > Fashion)
    66     function get_bol_wc_mapping_info() {
    67         saved_bol_category_data = settings.map_data[0].map_data
    68         let select = document.querySelector('#wc_cat_dropdown');
    69         select.value = settings.map_data[0].woocommerce_category_field;
    70     }
    71 
    72     function set_bol_wc_mapping_info(reload_data) {
     63    function set_bol_wc_mapping_info(e) {
     64        e.preventDefault();
     65        let table_data = get_table_data();
    7366        let data = {
    7467            'woocommerce_category_field': $("#wc_cat_dropdown").val(),
    75             'map_data': saved_bol_category_data,
     68            'map_data': table_data,
    7669            'action': 'set_shop_2_api_bol_wc_offer_mapping',
    7770            'nonce': settings.nonce,
     
    8275                if (response.data && response.data.response) {
    8376                    if (response.data.response.code === 200 || response.data.response.code === 201) {
    84                         if (reload_data === true) {
    85                             location.reload();
    86                         } else {
    87                             $('#common-success').text('Save Completed').show().fadeOut(5000);
    88                         }
    89                     } else {
    90                         alert("There was an error saving the data:" + response.data);
     77                        location.reload();
     78                        return true;
    9179                    }
     80                    alert("There was an error saving the data:" + response.data);
    9281                }
     82            } else {
     83                alert("There was an error saving the data:" + response.data);
    9384            }
    9485        });
    9586    }
    9687
    97     function update_cost_values(item_changed) {
    98         // Add commission and shipping
    99         let table_row = $(item_changed).parents('tr');
    100         let bol_cat_id = table_row.find('select').val();
    101         if (bol_cat_id !== "") {
    102             let bol_commission_amount = table_row.find('.bol_commission input').val();
    103             let bol_shipping_cost = table_row.find('.bol_shipping_cost  input').val();
    104             saved_bol_category_data[bol_cat_id]['bol_commission'] = bol_commission_amount;
    105             saved_bol_category_data[bol_cat_id]['bol_shipping'] = bol_shipping_cost;
    106         }
    107     }
    10888
    109     function update_saved_bol_category_data(dropdown_changed) {
    110         let prev_bol_cat_id = String($(dropdown_changed).data('old_value'));
    111         let new_bol_cat_id = String($(dropdown_changed).val());
    112         let wc_cat_id = $(dropdown_changed).data('bol_cat_slug');
    113 
    114         if (saved_bol_category_data && Object.keys(saved_bol_category_data).includes(new_bol_cat_id)) {
    115             // There is already a bol cat id in the saved data
    116             // If the previous one was undefined then just add it to the wc_field_values
    117             if (typeof (saved_bol_category_data[new_bol_cat_id]['wc_field_values']) !== "undefined") {
    118                 if (prev_bol_cat_id !== "" && prev_bol_cat_id !== 'undefined' && prev_bol_cat_id !== new_bol_cat_id) {
    119                     if ('wc_field_values' in saved_bol_category_data[prev_bol_cat_id]) {
    120                         saved_bol_category_data[prev_bol_cat_id]['wc_field_values'].remove(wc_cat_id);
    121                     }
    122                 }
    123                 if (!saved_bol_category_data[new_bol_cat_id]['wc_field_values'].includes(wc_cat_id)) {
    124                     saved_bol_category_data[new_bol_cat_id]['wc_field_values'].push(wc_cat_id);
    125                 }
    126             } else {
    127                 {
    128                     saved_bol_category_data[new_bol_cat_id]['wc_field_values'] = [wc_cat_id];
    129                 }
    130             }
    131         } else {
    132             // It is a new item.
    133             if (new_bol_cat_id !== "") {
    134                 if (!saved_bol_category_data || saved_bol_category_data.length === 0) {
    135                     saved_bol_category_data = {};
    136                 }
    137                 saved_bol_category_data[new_bol_cat_id] = {
    138                     'bol_cat_name': dropdown_changed.selectedOptions[0].innerHTML,
    139                     'wc_field_values': [wc_cat_id],
    140                     'mapping': default_mapping
    141                 }
    142             }
    143         }
    144         update_cost_values(dropdown_changed);
    145 
    146         if (Object.keys(saved_bol_category_data).includes(prev_bol_cat_id)) {
    147             if (typeof (saved_bol_category_data[prev_bol_cat_id]['wc_field_values']) !== "undefined") {
    148                 if (prev_bol_cat_id !== new_bol_cat_id) {
    149                     saved_bol_category_data[prev_bol_cat_id]['wc_field_values'].remove(wc_cat_id);
    150                 }
    151             }
    152         }
    153     }
    154 
    155     let default_mapping = {
    156         "ean": {
    157             "type": "Product",
    158             "value": "sku"
    159         },
    160         // "Name": {
    161         //     "type": "Product",
    162         //     "value": "name"
    163         // },
    164         // "Description": {
    165         //     "type": "Product",
    166         //     "value": "description"
    167         // },
    168         "stock.amount": {
    169             "type": "OwnValue",
    170             "value": "0"
    171         },
    172         "condition.name": {
    173             "type": "OwnValue",
    174             "value": "NEW"
    175         },
    176         "fulfilment.method": {
    177             "type": "OwnValue",
    178             "value": "FBR"
    179         },
    180         "Internal Reference": {
    181             "type": "Product",
    182             "value": "sku"
    183         },
    184         "unknownProductTitle": {
    185             "type": "Product",
    186             "value": "name"
    187         },
    188         "fulfilment.deliveryCode": {
    189             "type": "OwnValue",
    190             "value": "1-2d"
    191         },
    192         "stock.managedByRetailer": {
    193             "type": "OwnValue",
    194             "value": "true"
    195         },
    196         "pricing.bundlePrices.quantity": {
    197             "type": "OwnValue",
    198             "value": "1"
    199         },
    200         "pricing.bundlePrices.unitPrice": {
    201             "type": "Product",
    202             "value": "price"
    203         }
    204     }
     89    // let default_mapping = {
     90    //     "ean": {
     91    //         "type": "Product",
     92    //         "value": "sku"
     93    //     },
     94    //     // "Name": {
     95    //     //     "type": "Product",
     96    //     //     "value": "name"
     97    //     // },
     98    //     // "Description": {
     99    //     //     "type": "Product",
     100    //     //     "value": "description"
     101    //     // },
     102    //     "stock.amount": {
     103    //         "type": "OwnValue",
     104    //         "value": "0"
     105    //     },
     106    //     "condition.name": {
     107    //         "type": "OwnValue",
     108    //         "value": "NEW"
     109    //     },
     110    //     "fulfilment.method": {
     111    //         "type": "OwnValue",
     112    //         "value": "FBR"
     113    //     },
     114    //     "Internal Reference": {
     115    //         "type": "Product",
     116    //         "value": "sku"
     117    //     },
     118    //     "unknownProductTitle": {
     119    //         "type": "Product",
     120    //         "value": "name"
     121    //     },
     122    //     "fulfilment.deliveryCode": {
     123    //         "type": "OwnValue",
     124    //         "value": "1-2d"
     125    //     },
     126    //     "stock.managedByRetailer": {
     127    //         "type": "OwnValue",
     128    //         "value": "true"
     129    //     },
     130    //     "pricing.bundlePrices.quantity": {
     131    //         "type": "OwnValue",
     132    //         "value": "1"
     133    //     },
     134    //     "pricing.bundlePrices.unitPrice": {
     135    //         "type": "Product",
     136    //         "value": "price"
     137    //     }
     138    // }
    205139})(jQuery);
  • shop-2-api/trunk/assets/bol2api_mapping_scripts.js

    r2825412 r3007787  
    11( function( $ ) {
    2     let bol_wc_mapping_info = {};
    32    let woocommerce_metadata_option_data = [];
    43    let woocommerce_attribute_option_data = [];
     
    65    $( document ).ready( function() {
    76        $('#all-tabs').hide();
    8 
    9         // Getting saved data and populate it.
    10         get_bol_wc_mapping_info();
    11 
    12         // Pre Populate the Dropdown Values
     7        // // Attached change event to top dropdown
     8        $(document).on( 'change', '#wc_cat_dropdown', handle_cat_change);
     9
     10        // // Attaching the save function to the button.
     11        $('.shop-2-api-connect').on( 'click', '.shop-2-api-connect-save', submit_wc_bol_data);
     12        $('.shop-2-api-connect').on( 'click', '.shop-2-api-connect-save-sync', submit_wc_bol_data);
     13
     14        // Attach change event to section-to-map Dropdown
     15        $(document).on( 'change', 'select[name="section-to-map"]', handle_sec_to_map_change);
     16        // tabs
     17        $(document).on('click', '.nav-tab-wrapper a', handle_tab_click);
     18
    1319        get_woocommerce_metadata_option_data();
    1420        get_woocommerce_attribute_option_data();
    15 
    16         // Attaching the save function to the button.
    17         $('.shop-2-api-connect').on( 'click', '.shop-2-api-connect-save', submit_wc_bol_data);
    18         $('.shop-2-api-connect').on( 'click', '.shop-2-api-connect-save-sync', submit_wc_bol_data);
    19 
    20         // Attached change event to top dropdown
    21         $(document).on( 'change', '#wc_cat_dropdown', handle_cat_change);
    22 
    23         // Attach change event to section-to-map Dropdown
    24         $(document).on( 'change', 'select[name="section-to-map"]', handle_sec_to_map_change);
    25 
    26         // tabs
    27         $(document).on('click', '.nav-tab-wrapper a', handle_tab_click);
     21        set_wc_category_field_dropdown()
    2822    });
    2923
     
    3428        $(".nav-tab").removeClass("nav-tab-active");
    3529
    36         clicked_tab = $(this).attr('href');
     30        let clicked_tab = $(this).attr('href');
    3731        $(clicked_tab).show(800);
    3832        $(this).addClass('nav-tab-active');
     
    4135
    4236    function handle_sec_to_map_change() {
     37        debugger;
    4338        let current_selection = $(this).val();
    4439        // map container before populating new one
     
    5853                break;
    5954            case 'Product':
    60                 generated_field = set_wc_product_drowdown($(this).data());
     55                generated_field = set_wc_product_dropdown($(this).data());
    6156                break;
    6257        }
     
    150145    }
    151146
    152     function set_wc_product_drowdown(data) {
     147    function set_wc_product_dropdown(data) {
    153148        let woocommerce_option_properties = settings.wc_field_options.success.schema.properties;
    154149
     
    237232    }
    238233
    239     function add_product_mapping_row(product_dict, is_measurement = false) {
     234    function add_product_mapping_row(product_dict, is_measurement = false, product_response_data = {}) {
    240235        let description = product_dict.name;
    241236        let id = product_dict.id;
    242237        let required_val = product_dict.required;
    243         let mapped_value = get_mapping_value( product_dict.id);
     238        let mapped_value = product_response_data[product_dict.id];
    244239        let tooltip = product_dict.tooltip;
    245240        let dropdown_values = product_dict.ENUM;
     
    288283    }
    289284
    290     function add_offer_mapping_row(product_dict) {
     285    function add_offer_mapping_row(product_dict, product_response_data) {
    291286        let description = product_dict.name;
    292287        let id = product_dict.id;
    293288        let required_val = product_dict.required;
    294         let mapped_value = get_mapping_value( product_dict.id);
     289        let mapped_value = product_response_data[product_dict.id];
    295290        let tooltip = product_dict.tooltip;
    296291        let dropdown_values = product_dict.ENUM;
     
    356351        })
    357352
    358         let selected_mapping = bol_wc_mapping_info.map_data[$("#wc_cat_dropdown").val()];
    359         if (typeof(selected_mapping) == "undefined") {
    360             return bol_wc_mapping_info.map_data
    361         }
    362 
    363         selected_mapping['mapping'] = return_data;
    364         return bol_wc_mapping_info.map_data;
     353        return return_data;
    365354    }
    366355   
    367356    function submit_wc_bol_data() {
    368         var data = {
    369             'action' : 'set_shop_2_api_bol_wc_offer_mapping',
     357        debugger;
     358        let converted_data = convert_mapping_to_json();
     359
     360        let data = {
     361            'action' : 'set_shop_2_api_wc_to_bol_submit',
    370362            'nonce'  : settings.nonce,
    371             'map_data': convert_mapping_to_json()
     363            'map_data': converted_data,
     364            'bol_category_field': $("#wc_cat_dropdown").val()
    372365        };
    373366
     
    378371                    $('#common-success').show().fadeOut(5000);
    379372                    window.scrollTo(0, 0);
    380 
    381373                } else {
    382374                    alert("There was an error saving the data:" + response.data);
     
    387379
    388380    // Populate Dropdown and check if it must be selected.
    389     function set_wc_category_field_dropdown(items) {
     381    function set_wc_category_field_dropdown() {
     382        let items = settings.map_data;
    390383        let data_container = $('span[name="wc-data-container"]');
    391384        data_container.children().remove();
    392385
    393386        let _select = $('<select />', {name:"wc_cat_dropdown", id:"wc_cat_dropdown", class:"bol-cat-dropdown"});
    394        
    395         for (const item in items) {
    396             $('<option />', {value:item, text:items[item].bol_cat_name}).appendTo(_select);
    397         }
    398        
     387
     388        items.forEach(
     389            function(currentValue) {
     390                let select_value = {
     391                    value:currentValue.bol_category_code, text:currentValue.bol_category_name
     392                }
     393                $('<option />', select_value).appendTo(_select);
     394            }
     395        )
    399396        _select.appendTo(data_container);
    400         _select.change();
     397        _select.trigger('change');
    401398    }
    402399
     
    406403        // Add offer mapping rows
    407404        $.each(settings.offer_data, function(key, value){
    408             add_offer_mapping_row(value);
     405            add_offer_mapping_row(value, product_response_data.map_data);
    409406        })
    410        
    411         // Add Product mapping rows     
    412         $.each(product_response_data, function(index, value){
     407
     408        // Add Product mapping rows
     409        let enriched_data = product_response_data.woocommerce_enriched_model_data;
     410        $.each(enriched_data, function(index, value){
    413411            if (value['id'] === 'EAN') return;
    414             add_product_mapping_row(value);
     412            add_product_mapping_row(value, false, product_response_data.map_data);
    415413
    416414            if (value.type !== 'LABEL') {
     
    419417                unit_value.name = value.name + ' (Unit)';
    420418                unit_value.id = value.id + '_unit';
    421                 add_product_mapping_row(unit_value,true);
     419                add_product_mapping_row(unit_value,true, product_response_data.map_data);
    422420            }
    423421        });
    424422        $('.straighten').on('click', function(){
    425423            $(this).parent().parent().next("tr").toggle();
    426         });
    427     }
    428 
    429     // Get the mapping info back from bol.
    430     function get_bol_wc_mapping_info() {
    431         var data = {
    432             'action': 'get_bol_wc_mapping_info',
    433         };
    434 
    435         $.post(settings.ajaxurl, data, function(response) {
    436             if (response.success == true) {
    437                 if (response.data && response.data.response) {
    438                     if (response.data.response.code === 200) {
    439                         json_data = JSON.parse(response.data.body);
    440                         if (json_data.length === 0) {
    441                             console.log("No Data Retrieved");
    442                         } else {
    443                             // Set dropdown
    444                             bol_wc_mapping_info = json_data[0];
    445                             set_wc_category_field_dropdown(bol_wc_mapping_info.map_data);
    446                         }
    447                     } else {
    448                         alert("There was an error retrieving the data:" + response);
    449                     }
    450                 }
    451             }
    452424        });
    453425    }
     
    465437
    466438    // Populate the table
    467     function get_bol_category_info_by_value(cat_name)
     439    function get_bol_category_info_by_value(cat_code)
    468440    {
    469         let data = {
    470             'action': 'get_bol_category_info_by_value',
    471             'value' : cat_name,
    472             'nonce'  : settings.nonce,
    473         };
    474 
    475         $.post(settings.ajaxurl, data, function(response) {
    476             if (response.success == true) {
    477                 if (response.data && response.data.response) {
    478                     if (response.data.response.code === 200) {
    479                         // Populate Table
    480                         populate_table(JSON.parse(response.data.body));
    481                     } else {
    482                         alert("There was an error retrieving the data:" + response.data);
    483                     }
    484                 }
    485             } else {
    486                 alert("There was an error retrieving the data:" + response.data);
    487             }
    488         });
    489     }
    490 
    491     function get_mapping_value(mapping_value) {
    492         let selected_mapping = bol_wc_mapping_info.map_data[$("#wc_cat_dropdown").val()];
    493         if (typeof(selected_mapping.mapping) !== "undefined") {
    494             return selected_mapping.mapping[mapping_value]
    495         }
    496         return undefined;
     441        let items = settings.map_data;
     442        for (let i in items) {
     443            let item = items[i]
     444            if (item.bol_category_code === cat_code) {
     445                populate_table(item);
     446                return;
     447            }
     448        }
    497449    }
    498450
     
    500452    function get_woocommerce_metadata_option_data()
    501453    {
    502         var data = {
     454        let data = {
    503455            'action': 'get_woocommerce_values',
    504456            'value' : 'meta_data'
     
    522474    function get_woocommerce_attribute_option_data()
    523475    {
    524         var data = {
     476        let data = {
    525477            'action': 'get_woocommerce_values',
    526478            'value' : 'attributes'
     
    546498   
    547499            // Keep track of the selected option.
    548             var selectedValue = $(this).val();
     500            let selectedValue = $(this).val();
    549501   
    550502            // Sort all the options by text. I could easily sort these by val.
  • shop-2-api/trunk/includes/Api/Shop2ApiConnect.php

    r2982442 r3007787  
    302302    {
    303303        return wp_remote_get(
    304             $this->shop_2_api_url . '/map/api/wc-bol-map/', ['headers' => $this->header]
     304            $this->shop_2_api_url . '/map/api/wc-product-sync-options/', ['headers' => $this->header]
     305        );
     306    }
     307
     308    public function get_bol_wc_mapping_detail_info()
     309    {
     310        return wp_remote_get(
     311            $this->shop_2_api_url . '/map/api/wc-product-sync-data/', ['headers' => $this->header]
    305312        );
    306313    }
     
    361368    }
    362369
    363     public function set_bol_wc_mapping($woocommerce_category_field, $map_data, $condition = NULL)
    364     {
    365         $order = $this->get_order();
    366         $mapping_url = '/map/api/wc-bol-map/';
     370    public function set_bol_wc_mapping($woocommerce_category_field, $map_data)
     371    {
     372        update_option('woocommerce_category_field', $woocommerce_category_field);
     373
     374        $mapping_url = $this->shop_2_api_url . '/map/save_product_map/';
    367375        $method = 'POST';
    368376
    369         //Check if there is any mappings
    370         $mappings = wp_remote_retrieve_body($this->get_bol_wc_mapping_info());
    371         $json_mappings = json_decode($mappings, true);
    372 
    373         if (count($json_mappings) != 0) {
    374             $mapping_url = $mapping_url . $json_mappings[0]["id"] . '/';
    375             $method = 'PATCH';
    376         }
    377 
    378         $data = [
    379             "woocommerce_category_field" => $woocommerce_category_field,
    380             "map_data" => $map_data,
    381             "product" => $order["id"]
    382         ];
    383 
    384         return wp_remote_post(
    385             $this->shop_2_api_url . $mapping_url,
     377        $data = ["map_data" => $map_data,"woocommerce_category_field" => $woocommerce_category_field];
     378
     379        return wp_remote_post(
     380            $mapping_url,
    386381            [
    387382                'headers' => $this->header,
     
    392387    }
    393388
    394     public function set_wc_to_bol_submit($map_data)
    395     {
    396         $mapping_url = '/woocommerce/bol-to-wc-submit/';
    397         $method = 'POST';
     389    public function set_wc_to_bol_submit($bol_category_field, $map_data)
     390    {
     391        $mapping_url = '/map/api/wc-product-map-data/' . $bol_category_field . '/';
     392        $method = 'PATCH';
    398393
    399394        return wp_remote_post(
  • shop-2-api/trunk/includes/Base/AjaxButtonActions.php

    r2982442 r3007787  
    233233        $shop_2_api_response = $this->shop_2_api_connections->set_wc_to_bol_submit
    234234        (
    235             json_encode($_POST['map_data'])
     235            $_POST['bol_category_field'], json_encode($_POST['map_data'])
    236236        );
    237237        $this->handle_api_response($shop_2_api_response);
  • shop-2-api/trunk/includes/Base/Enqueue.php

    r2982442 r3007787  
    2020    public function register(): void
    2121    {
     22        //Add filter so that query will return products and variations
     23        add_filter("woocommerce_rest_product_object_query",
     24            function (array $args){ $args["post_type"] = array( 'product', 'product_variation' ); return $args; },
     25            10, 1
     26        );
     27
    2228        add_action('admin_notices', array($this, 'get_server_user_message'));
    2329
     
    235241            'ajaxurl' => admin_url('admin-ajax.php'),
    236242            'nonce' => wp_create_nonce('ajax-nonce'),
    237             'map_data' => $map_data
     243            'map_data' => $map_data,
     244            'map_category' => get_option('woocommerce_category_field', 'main_categories'),
    238245        ));
    239246    }
     
    248255        //Get Product Data
    249256        $offer_data = $this->handle_api_response($shop_2_api_connection->get_bol_offer_info());
     257        $map_data = $this->handle_api_response($shop_2_api_connection->get_bol_wc_mapping_detail_info());
    250258
    251259        wp_localize_script('bol2api_scripts_common', 'settings', array(
     
    253261            'nonce' => wp_create_nonce('ajax-nonce'),
    254262            'wc_field_options' => $wc_field_options,
    255             'offer_data' => $offer_data
     263            'offer_data' => $offer_data,
     264            'map_data' => $map_data,
    256265        ));
    257266    }
  • shop-2-api/trunk/includes/Pages/Admin.php

    r2975851 r3007787  
    7979                add_submenu_page(
    8080                    'shop2api_plugin', //Parent Slug
    81                     'Map WooCommerce Category', // Page Title
    82                     'Map WooCommerce Category', // Menu Title
     81                    'Map Bol Category', // Page Title
     82                    'Map Bol Category', // Menu Title
    8383                    'manage_options', // Capability
    8484                    'shop2api_woocommerce_category', // Menu Slug
    85                     array($this, 'wc_category_selection_page'), // Function
     85                    array($this, 'bol_2_wc_product_settings'), // Function
    8686                );
    8787
     
    229229        }
    230230
    231         public function wc_category_selection_page() 
    232         {
     231        public function wc_category_selection_page(): void
     232        {
    233233            require_once SHOP2API_PLUGIN_PATH . '/includes/Tables/WcCategorySelection.php';
    234234            $ListTable = new Shop2Api_WcCategorySelection();
     
    256256        }
    257257
     258        public function bol_2_wc_product_settings(): void
     259        {
     260            require_once SHOP2API_PLUGIN_PATH . '/includes/Tables/Wc2BolProductSettings.php';
     261            $ListTable = new Shop2Api_Wc2BolProductSettings();
     262            echo wp_kses('<div class="wrap">', $this->allowed_html);
     263            echo wp_kses('<form method="post">', $this->allowed_html);
     264            // Common Header to be included everywhere and js should also be in the common.js
     265            $shop2api_header = "WooCommerce To Bol Category Mapping";
     266            $shop2api_header_detail = "To map your products to bol, we need to know which Category in WooCommerce will
     267            map to your category in Bol.com. </br>
     268            <b>For Example: You have a category in WooCommerce 'HOUT' which you can map to 'HOUTKACHEL' a category
     269            on bol.com</b> </br>
     270            Bol Commission and Bol Shipping Costs will be added to the price field which is mapped on the next step.
     271            <div class='disclaimer1'>* When you complete your mapping remember to save your changes.</div>";
     272            require_once SHOP2API_PLUGIN_PATH . 'templates/common-header.php';
     273
     274            echo wp_kses('<div class="content" style="padding: 10px 20px">', $this->allowed_html);
     275
     276            $ListTable->prepare_items();
     277            // Render Table
     278            $ListTable->display();
     279            echo wp_kses('<button id="category-save" class="shop-2-api-connect-save">Save</button>', $this->allowed_html);
     280            echo wp_kses('</form">', $this->allowed_html);
     281            echo wp_kses('</div>', $this->allowed_html);
     282            echo wp_kses('</div>', $this->allowed_html);
     283        }
     284
    258285        public function bol_koopblok_service()
    259286        {
  • shop-2-api/trunk/readme.txt

    r3005018 r3007787  
    33Plugin URI: https://wordpress.org/plugins/shop-2-api/
    44Tags: WooCommerce, Bol
    5 Stable Tag: 1.0.28.6
     5Stable Tag: 1.0.29.0
    66Requires at least: 5.0
    77Requires PHP: 7.2
    8 Tested up to: 6.3
     8Tested up to: 6.4
    99Author: Adriaan Coetzee
    1010Author URI: https://shop2API.com/
     
    1611615) Fix bug where product variants is not retrieved
    162162
     163= 1.0.29 =
     1641) Reworked Bol.com Product and Offer Mapping
     165
    163166
    164167== Instructions ==
  • shop-2-api/trunk/shop-2-api.php

    r3005018 r3007787  
    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.28.6
     7Version: 1.0.29.0
    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.28.6');
     36define ('VERSION', '1.0.29.0');
    3737
    3838// Register items in the project.
  • shop-2-api/trunk/templates/wc-to-bol-mapping.php

    r2825412 r3007787  
    88        <div id="all-tabs">
    99            <h2 class="nav-tab-wrapper">
    10                 <a href="#offer-table" class="nav-tab nav-tab-active">Offer Data</a>
    11                 <a href="#product-table" class="nav-tab">Product Data</a>
     10                <a href="#offer-table" class="nav-tab nav-tab-active">Offer Mapping</a>
     11                <a href="#product-table" class="nav-tab">Product Mapping</a>
    1212            </h2>
    1313
Note: See TracChangeset for help on using the changeset viewer.