Skip to content

Commit

Permalink
Update chosen category method documentation and typo.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aunshon committed Jan 20, 2025
1 parent dbb1e05 commit 019b7cf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions assets/src/js/product-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@
} );
},

unormatMoney( amount ) {
unformatMoney( amount ) {
return accounting.unformat( amount, dokan.mon_decimal_point );
},

Expand All @@ -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') );
Expand Down
19 changes: 17 additions & 2 deletions includes/ProductCategory/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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
*
Expand All @@ -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(
Expand Down

0 comments on commit 019b7cf

Please sign in to comment.