From fd0929bdf8434ab901364e9dc9479fe0c686ba43 Mon Sep 17 00:00:00 2001 From: Shazahanul Islam Shohag Date: Thu, 2 Nov 2023 10:11:21 +0600 Subject: [PATCH 1/2] update: display Not purchasable notice for own product closes: https://github.com/getdokan/dokan-pro/issues/2782 --- includes/Product/Hooks.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/includes/Product/Hooks.php b/includes/Product/Hooks.php index 0e67bd006d..11f72aeab3 100644 --- a/includes/Product/Hooks.php +++ b/includes/Product/Hooks.php @@ -49,7 +49,7 @@ public function __construct() { // Remove product type filter if pro not exists. add_filter( 'dokan_product_listing_filter_args', [ $this, 'remove_product_type_filter' ] ); - + add_action( 'woocommerce_before_single_product', [ $this, 'own_product_not_purchasable_notice' ] ); // Init Product Cache Class new VendorStoreInfo(); new ProductCache(); @@ -399,4 +399,21 @@ public function remove_product_type_filter( $args ) { return $args; } + + /** + * Display own product not punchable notice. + * + * @since DOKAN_SINCE + * + * @return void + */ + public function own_product_not_purchasable_notice() { + global $product; + + if ( ! dokan_is_product_author( $product->get_id() ) ) { + return; + } + + wc_print_notice( __( 'As this is your own product, the "Add to Cart" button has been removed. Please visit as a guest to view it.', 'dokan-lite' ), 'notice' ); + } } From 80709a52d119dcbacbd9d16947239723cbc8f7f3 Mon Sep 17 00:00:00 2001 From: Shazahanul Islam Shohag Date: Thu, 2 Nov 2023 15:35:18 +0600 Subject: [PATCH 2/2] update: remove Not purchasable notice for own product in auction product --- includes/Product/Hooks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Product/Hooks.php b/includes/Product/Hooks.php index 11f72aeab3..0b1d14a8d5 100644 --- a/includes/Product/Hooks.php +++ b/includes/Product/Hooks.php @@ -410,7 +410,7 @@ public function remove_product_type_filter( $args ) { public function own_product_not_purchasable_notice() { global $product; - if ( ! dokan_is_product_author( $product->get_id() ) ) { + if ( ! dokan_is_product_author( $product->get_id() ) || 'auction' === $product->get_type() ) { return; }