';print_r($data);die; $nested = array(); //loop over each category foreach($data as &$category){ //is there is no children array, add it if(!isset($category['Children'])){ $category['Children'] = array(); } //check if there is a matching parent if(isset($data[$category['CategoryParentID']]) && $category['CategoryLevel'] != 1){ //add this under the parent as a child by reference if(!isset($data[$category['CategoryParentID']]['Children'])){ $data[$category['CategoryParentID']]['Children'] = array(); } $data[$category['CategoryParentID']]['Children'][$category['CategoryID']] = &$category; //else, no parent found, add at top level } else { $nested[$category['CategoryID']] = &$category; } } unset($category); // echo '';print_r($nested);die; return $nested; } function ced_ebay_flatten_nested_category_data($nested, $parent=''){ $out = array(); foreach($nested as $category){ $categoryName = $parent.$category['CategoryName']; if(isset($category['LeafCategory']) && true == $category['LeafCategory']){ $out[$category['CategoryID']] = $categoryName; } $out += ced_ebay_flatten_nested_category_data($category['Children'], $categoryName.' > '); //recurse for each child } return $out; } // echo '';print_r(count($ebay_site_category_tree));die; $ebay_site_category_structure = ced_ebay_flatten_nested_category_data(ced_ebay_make_nested_category_data($ebay_site_category_tree)); // echo '';print_r($result);die; ?><h2 style="font-size:18px;"><b>Add Custom Profile</h2> </div> <div class="ced-ebay-v2-actions"> <a class="ced-ebay-v2-btn" href="<?php echo esc_attr( admin_url( 'admin.php?page=ced_ebay§ion=profiles-view&user_id=' . $user_id ) ); ?>"> Go Back </a> <a class="ced-ebay-v2-btn" href="https://docs.woocommerce.com/document/ebay-integration-for-woocommerce/#section-8" target="_blank"> Documentation </a> </div> </div>
<script> jQuery(document).ready(function() { jQuery(".ced_ebay_cst_prf_ebay_cat").selectWoo({ width: '100%', placeholder: { id: "", placeholder: "Choose." }, language: { inputTooShort: function (args) { return "Please enter 3 or more words."; }, noResults: function () { return "Not Found."; }, searching: function () { return "Searching..."; } }, minimumInputLength: 3 }); }); </script> <style> .bootstrap-select .dropdown-menu { max-width: 100% !important; } </style>Profile Details
this is a description of the section
</h3> </div> <div class="col-xl-6 col-lg-6 col-md-6 col-sm-6 col-12"> <div class="form-group"> <label for="fullName">Profile Name</label> <input type="text" class="form-control" id="fullName" placeholder="Enter full name"> </div> </div> <div class="col-xl-6 col-lg-6 col-md-6 col-sm-6 col-12"> <div class="form-group"> <label for="eMail">WooCommerce Category</label> <?php wp_dropdown_categories( array( 'show_option_all' => esc_html__( 'Select Category', 'woocommerce' ), 'orderby' => 'name', 'hierarchical' => 1, 'echo' => 1, 'value_field' => 'term_id', 'taxonomy' => 'product_cat', 'name' => 'ced_ebay_custom_profile_woo_category', 'class' => 'ced_ebay_custom_profile_woo_category form-control', ) ); ?> </div> </div> <div class="col-xl-6 col-lg-6 col-md-6 col-sm-6 col-12"> <div class="form-group"> <label for="ebay_site_category">eBay Site Category</label> <select class="form-control ced_ebay_cst_prf_ebay_cat"> <?php if(!empty($ebay_site_category_structure)){ foreach($ebay_site_category_structure as $key => $ebay_site_cat){ ?> <option value="<?php echo esc_attr($key); ?>"><?php echo $ebay_site_cat; ?></option> <?php } } ?> </select> </div> </div> </div> <hr/> <div class="row gutters"> <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12"> <h6 class="mt-3 mb-2 text-primary">Address</h6> </div> <div class="col-xl-6 col-lg-6 col-md-6 col-sm-6 col-12"> <div class="form-group"> <label for="Street">Street</label> <input type="name" class="form-control" id="Street" placeholder="Enter Street"> </div> </div> <div class="col-xl-6 col-lg-6 col-md-6 col-sm-6 col-12"> <div class="form-group"> <label for="ciTy">City</label> <input type="name" class="form-control" id="ciTy" placeholder="Enter City"> </div> </div> <div class="col-xl-6 col-lg-6 col-md-6 col-sm-6 col-12"> <div class="form-group"> <label for="sTate">State</label> <input type="text" class="form-control" id="sTate" placeholder="Enter State"> </div> </div> <div class="col-xl-6 col-lg-6 col-md-6 col-sm-6 col-12"> <div class="form-group"> <label for="zIp">Zip Code</label> <input type="text" class="form-control" id="zIp" placeholder="Zip Code"> </div> </div> </div> <div class="row gutters"> <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12"> <div class="text-right"> <button type="button" id="submit" name="submit" class="btn btn-secondary">Cancel</button> <button type="button" id="submit" name="submit" class="btn btn-primary">Update</button> </div> </div> </div> </div>
Last active
April 6, 2022 09:50
-
-
Save ali-cedcoss/e07f0e34b38864d13a0060c6b54d2385 to your computer and use it in GitHub Desktop.
ebay custom profile with support for category leaf node mapping
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment