From 019b7cffcf0e9dd41e14d450054f7af9a77a95cc Mon Sep 17 00:00:00 2001 From: Aunshon <32583103+Aunshon@users.noreply.github.com> Date: Mon, 20 Jan 2025 10:25:05 +0600 Subject: [PATCH] Update chosen category method documentation and typo. --- assets/src/js/product-editor.js | 4 ++-- includes/ProductCategory/Helper.php | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/assets/src/js/product-editor.js b/assets/src/js/product-editor.js index 02f79fc7f5..4a96efc85b 100755 --- a/assets/src/js/product-editor.js +++ b/assets/src/js/product-editor.js @@ -985,7 +985,7 @@ } ); }, - unormatMoney( amount ) { + unformatMoney( amount ) { return accounting.unformat( amount, dokan.mon_decimal_point ); }, @@ -995,7 +995,7 @@ let vandorPrice = $( '.simple-product span.vendor-price' ).text(); - vandorPrice = Dokan_Editor.unormatMoney( vandorPrice ); + vandorPrice = Dokan_Editor.unformatMoney( vandorPrice ); if ( vandorPrice < 0 ) { $( $('.dokan-product-less-price-alert').removeClass('dokan-hide') ); diff --git a/includes/ProductCategory/Helper.php b/includes/ProductCategory/Helper.php index dd50221d5e..67726d25a8 100644 --- a/includes/ProductCategory/Helper.php +++ b/includes/ProductCategory/Helper.php @@ -35,7 +35,13 @@ public static function is_any_category_selection_enabled() { } /** - * Returns products category. + * Returns products category. If the category selection is single, it will return the first category of the product. + * If the category selection is multiple, it will return all the categories of the product. + * If the category selection is single and the product has multiple categories, it will return the first category. + * If you want to get the chosen category of a product as it is saved in the database and not considering the category selection setting, + * then use the function self::get_product_chosen_category + * + * @see self::get_product_chosen_category * * @since 3.6.2 * @@ -256,6 +262,15 @@ public static function enqueue_and_localize_dokan_multistep_category() { /** * Returns the chosen category of a product. + * The purpose of this function is to get the chosen category of a product. It will return the category ids as saved + * in the database. it will not consider if the setting in dokan setting is single or multiple category selection. + * It will return the saved category ids as it is. And if the product is a variation product, it will find the parent + * product id and return the chosen category of the parent product. + * + * It is not recommended to use this function to get the chosen category of a product by the chosen category setting. + * Instead, use the function self::get_saved_products_category + * + * @see self::get_saved_products_category * * @since 3.7.0 * @@ -277,7 +292,7 @@ public static function get_product_chosen_category( $product ) { $chosen_product_cat = get_post_meta( $product_id, 'chosen_product_cat', true ); if ( ! is_array( $chosen_product_cat ) ) { - return $chosen_product_cat; + return []; } return array_filter(