Skip to content

Commit

Permalink
Merge branch 'release/3.14.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Aunshon committed Dec 6, 2024
2 parents baf4c12 + e7c16b9 commit 7a35e11
Show file tree
Hide file tree
Showing 29 changed files with 350 additions and 131 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### v3.13.0 ( Nov 06, 2024 ) ###

- **feat:** Replaced the Dokan array container with the League Container, ensuring backward compatibility for seamless performance and enhanced flexibility.
- **feat:** Updated Dokan to be fully compatible with WooCommerce Analytics Reports
-
### v3.12.6 ( Oct 24, 2024 ) ###

- **fix:** Fixed js error on frontend pages.
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
**WC requires at least:** 8.0.0
**WC tested up to:** 9.4.2
**Requires PHP:** 7.4
**Stable tag:** 3.14.1
**Stable tag:** 3.14.2
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -347,6 +347,10 @@ A. Just install and activate the PRO version without deleting the free plugin. A

## Changelog ##

### v3.14.2 ( Dec 06, 2024 ) ###

- **update:** Added commission setting option in product bulk edit for Admin.

### v3.14.1 ( Dec 04, 2024 ) ###

- **fix:** Fixed a issue in the commission upgrader to deal with empty values for product and vendor.
Expand All @@ -373,11 +377,6 @@ A. Just install and activate the PRO version without deleting the free plugin. A
- **update:** Compatibility with the Printful Integration Module added.
- **fix:** Improved logic to ensure the `add new category` button only appears when appropriate conditions are met, enhancing user experience.

### v3.13.0 ( Nov 06, 2024 ) ###

- **feat:** Replaced the Dokan array container with the League Container, ensuring backward compatibility for seamless performance and enhanced flexibility.
- **feat:** Updated Dokan to be fully compatible with WooCommerce Analytics Reports


[CHECK THE FULL CHANGELOG](https://github.com/getdokan/dokan/blob/develop/CHANGELOG.md).

Expand Down
2 changes: 1 addition & 1 deletion dokan-class.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class WeDevs_Dokan {
*
* @var string
*/
public $version = '3.14.1';
public $version = '3.14.2';

/**
* Instance of self
Expand Down
2 changes: 1 addition & 1 deletion dokan.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Dokan
* Plugin URI: https://dokan.co/wordpress/
* Description: An e-commerce marketplace plugin for WordPress. Powered by WooCommerce and weDevs.
* Version: 3.14.1
* Version: 3.14.2
* Author: weDevs
* Author URI: https://dokan.co/
* Text Domain: dokan-lite
Expand Down
46 changes: 46 additions & 0 deletions includes/Admin/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace WeDevs\Dokan\Admin;

use WeDevs\Dokan\Product\Hooks as ProductHooks;
use WP_Post;

// don't call the file directly
Expand Down Expand Up @@ -35,6 +36,9 @@ public function __construct() {

// Ajax hooks
add_action( 'wp_ajax_dokan_product_search_author', [ $this, 'search_vendors' ] );

add_action( 'woocommerce_product_bulk_edit_end', [ $this, 'add_product_commission_bulk_edit_field' ] );
add_action( 'woocommerce_product_bulk_edit_save', [ $this, 'save_custom_bulk_edit_field' ], 10, 1 );
}

/**
Expand Down Expand Up @@ -223,4 +227,46 @@ public function update_pages( $value, $name ) {

return array_replace_recursive( $current_settings, $value );
}

/**
* Add commission settings in bulk product edit.
*
* @since 3.14.2
*
* @return void
*/
public function add_product_commission_bulk_edit_field() {
dokan_get_template_part( 'products/dokan-products-edit-bulk-commission', '', [] );
}

/**
* Save commission settings from bulk product edit
*
* @since 3.14.2
*
* @param \WC_Product $product
*
* @return void
*/
public function save_custom_bulk_edit_field( $product ) {
$excluded_product_types = apply_filters( 'dokan_excluded_product_types_for_bulk_edit', [ 'product_pack', 'external', 'grouped' ] );
$dokan_advertisement_product_id = intval( get_option( 'dokan_advertisement_product_id', '' ) );
$dokan_reverse_withdrawal_product_id = intval( get_option( 'dokan_reverse_withdrawal_product_id', '' ) );
$product_id = $product->get_id();

if (
! current_user_can( 'manage_woocommerce' ) ||
in_array( $product->get_type(), $excluded_product_types, true ) ||
$product_id === $dokan_advertisement_product_id ||
$product_id === $dokan_reverse_withdrawal_product_id
) {
return;
}

if ( ! isset( $_REQUEST['dokan_override_bulk_product_commission'] ) || intval( sanitize_text_field( $_REQUEST['dokan_override_bulk_product_commission'] ) ) !== 1 ) { // phpcs:ignore
return;
}

ProductHooks::save_per_product_commission_options( $product->get_id(), $_REQUEST ); // phpcs:ignore
}
}
40 changes: 27 additions & 13 deletions includes/Product/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace WeDevs\Dokan\Product;

use WeDevs\Dokan\Commission\Formula\Fixed;
use WeDevs\Dokan\ProductCategory\Helper;
use WC_Product;

Expand Down Expand Up @@ -521,37 +522,50 @@ class="woocommerce-help-tip"
*
* @since 2.4.12
*
* @param integer $post_id
* @param integer $post_id
* @param array $data
*
* @return void
*/
public static function save_per_product_commission_options( $post_id ) {
public static function save_per_product_commission_options( $post_id, $data = [] ) {
if ( ! current_user_can( 'manage_woocommerce' ) ) {
return;
}

$commission_type = '';
$commission_type = Fixed::SOURCE;
$admin_commission = '';
$additional_fee = '';
$data = empty( $data ) ? $_POST : $data; // phpcs:ignore

if ( isset( $_POST['_per_product_admin_commission_type'] ) ) { // phpcs:ignore
$commission_type = ! empty( $_POST['_per_product_admin_commission_type'] ) ? sanitize_text_field( $_POST['_per_product_admin_commission_type'] ) : 'percentage'; // phpcs:ignore
update_post_meta( $post_id, '_per_product_admin_commission_type', $commission_type );
if ( isset( $data['_per_product_admin_commission_type'] ) ) {
$commission_type = ! empty( $data['_per_product_admin_commission_type'] ) ? sanitize_text_field( $data['_per_product_admin_commission_type'] ) : Fixed::SOURCE;
}

if ( isset( $_POST['_per_product_admin_commission'] ) ) { // phpcs:ignore
$_per_product_admin_commission = wc_format_decimal( sanitize_text_field( $_POST['_per_product_admin_commission'] ) ); // phpcs:ignore
if ( isset( $data['_per_product_admin_commission'] ) ) {
$_per_product_admin_commission = wc_format_decimal( sanitize_text_field( $data['_per_product_admin_commission'] ) );

if ( 0 <= $_per_product_admin_commission && 100 >= $_per_product_admin_commission ) {
$admin_commission = ( '' === $_POST['_per_product_admin_commission'] ) ? '' : $_per_product_admin_commission; // phpcs:ignore
$admin_commission = ( '' === $data['_per_product_admin_commission'] ) ? '' : $_per_product_admin_commission;
}
}

if ( isset( $_POST['_per_product_admin_additional_fee'] ) ) { // phpcs:ignore
$additional_fee = ( '' === $_POST['_per_product_admin_additional_fee'] ) ? '' : sanitize_text_field( $_POST['_per_product_admin_additional_fee'] ); // phpcs:ignore
if ( isset( $data['_per_product_admin_additional_fee'] ) ) {
$additional_fee = ( '' === $data['_per_product_admin_additional_fee'] ) ? '' : sanitize_text_field( $data['_per_product_admin_additional_fee'] );

if ( 0 > $additional_fee ) {
$additional_fee = '';
}

$additional_fee = wc_format_decimal( $additional_fee );
}

update_post_meta( $post_id, '_per_product_admin_commission', $admin_commission );
update_post_meta( $post_id, '_per_product_admin_additional_fee', wc_format_decimal( $additional_fee ) );
dokan()->product->save_commission_settings(
$post_id,
[
'type' => $commission_type,
'percentage' => $admin_commission,
'flat' => $additional_fee,
]
);
}
}
37 changes: 22 additions & 15 deletions languages/dokan-lite.pot
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Copyright (c) 2024 weDevs Pte. Ltd. All Rights Reserved.
msgid ""
msgstr ""
"Project-Id-Version: Dokan 3.14.1\n"
"Project-Id-Version: Dokan 3.14.2\n"
"Report-Msgid-Bugs-To: https://dokan.co/contact/\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2024-12-04T09:23:45+00:00\n"
"POT-Creation-Date: 2024-12-06T12:33:06+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.11.0\n"
"X-Domain: dokan-lite\n"
Expand Down Expand Up @@ -195,7 +195,7 @@ msgstr ""
msgid "Commision: "
msgstr ""

#: includes/Admin/Hooks.php:66
#: includes/Admin/Hooks.php:70
#: includes/Admin/Settings.php:590
#: includes/Admin/Settings.php:601
#: includes/Admin/Settings.php:612
Expand All @@ -212,16 +212,16 @@ msgstr ""
msgid "Vendor"
msgstr ""

#: includes/Admin/Hooks.php:93
#: includes/Admin/Hooks.php:97
#: assets/js/vue-admin.js:2
msgid "Select vendor"
msgstr ""

#: includes/Admin/Hooks.php:99
#: includes/Admin/Hooks.php:103
msgid "You can search vendors and assign them."
msgstr ""

#: includes/Admin/Hooks.php:112
#: includes/Admin/Hooks.php:116
msgid "Unauthorized operation"
msgstr ""

Expand Down Expand Up @@ -698,6 +698,7 @@ msgstr ""
#: includes/Order/Admin/Hooks.php:95
#: includes/ReverseWithdrawal/Helper.php:65
#: templates/orders/commission-meta-box-html.php:66
#: templates/products/dokan-products-edit-bulk-commission.php:17
msgid "Commission"
msgstr ""

Expand All @@ -719,7 +720,7 @@ msgstr ""

#: includes/Admin/Settings.php:523
#: includes/Admin/Settings.php:563
#: includes/Product/Hooks.php:483
#: includes/Product/Hooks.php:484
#: assets/js/vue-admin.js:2
msgid "Admin Commission"
msgstr ""
Expand Down Expand Up @@ -1840,7 +1841,7 @@ msgid "Delete"
msgstr ""

#: includes/Ajax.php:529
#: includes/Product/Hooks.php:58
#: includes/Product/Hooks.php:59
msgid "Error: Nonce verification failed"
msgstr ""

Expand Down Expand Up @@ -3899,6 +3900,7 @@ msgid "privacy policy"
msgstr ""

#: includes/functions.php:3256
#: templates/products/dokan-products-edit-bulk-commission.php:28
msgid "Fixed"
msgstr ""

Expand Down Expand Up @@ -4556,7 +4558,7 @@ msgid "Catalog"
msgstr ""

#: includes/Product/functions.php:363
#: includes/Product/Hooks.php:195
#: includes/Product/Hooks.php:196
#: templates/products/listing-filter.php:85
msgid "Search"
msgstr ""
Expand Down Expand Up @@ -4606,29 +4608,29 @@ msgstr ""
msgid "Relevance"
msgstr ""

#: includes/Product/Hooks.php:65
#: includes/Product/Hooks.php:66
msgid "Products not found with this search"
msgstr ""

#: includes/Product/Hooks.php:154
#: includes/Product/Hooks.php:155
#: templates/orders/commission-meta-box-html.php:111
msgid "SKU:"
msgstr ""

#: includes/Product/Hooks.php:191
#: includes/Product/Hooks.php:192
msgid "Enter product name"
msgstr ""

#: includes/Product/Hooks.php:199
#: includes/Product/Hooks.php:200
msgid "Shop order"
msgstr ""

#: includes/Product/Hooks.php:417
#: includes/Product/Hooks.php:418
msgid "As this is your own product, the \"Add to Cart\" button has been removed. Please visit as a guest to view it."
msgstr ""

#: includes/Product/Hooks.php:487
#: includes/Product/Hooks.php:488
#: includes/Product/Hooks.php:489
#: assets/js/vue-admin.js:2
msgid "When the value is 0, no commissions will be deducted from this vendor."
msgstr ""
Expand Down Expand Up @@ -7465,6 +7467,7 @@ msgid "Reviews cannot be posted for products that you own."
msgstr ""

#: includes/wc-template.php:171
#: templates/products/dokan-products-edit-bulk-commission.php:20
msgid "— No change —"
msgstr ""

Expand Down Expand Up @@ -9065,6 +9068,10 @@ msgstr ""
msgid "Done"
msgstr ""

#: templates/products/dokan-products-edit-bulk-commission.php:21
msgid "Change to:"
msgstr ""

#: templates/products/download-virtual.php:4
#: templates/products/products-listing-row.php:245
msgid "Downloadable"
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dokan",
"version": "3.14.1",
"version": "3.14.2",
"description": "A WordPress marketplace plugin",
"author": "weDevs",
"license": "GPL",
Expand Down
11 changes: 5 additions & 6 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Tested up to: 6.7.1
WC requires at least: 8.0.0
WC tested up to: 9.4.2
Requires PHP: 7.4
Stable tag: 3.14.1
Stable tag: 3.14.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -347,6 +347,10 @@ A. Just install and activate the PRO version without deleting the free plugin. A

== Changelog ==

= v3.14.2 ( Dec 06, 2024 ) =

- **update:** Added commission setting option in product bulk edit for Admin.

= v3.14.1 ( Dec 04, 2024 ) =

- **fix:** Fixed a issue in the commission upgrader to deal with empty values for product and vendor.
Expand All @@ -373,11 +377,6 @@ A. Just install and activate the PRO version without deleting the free plugin. A
- **update:** Compatibility with the Printful Integration Module added.
- **fix:** Improved logic to ensure the `add new category` button only appears when appropriate conditions are met, enhancing user experience.

= v3.13.0 ( Nov 06, 2024 ) =

- **feat:** Replaced the Dokan array container with the League Container, ensuring backward compatibility for seamless performance and enhanced flexibility.
- **feat:** Updated Dokan to be fully compatible with WooCommerce Analytics Reports


[CHECK THE FULL CHANGELOG](https://github.com/getdokan/dokan/blob/develop/CHANGELOG.md).

Expand Down
Loading

0 comments on commit 7a35e11

Please sign in to comment.