diff --git a/includes/Product/Hooks.php b/includes/Product/Hooks.php index 477038bfec..87d7f6a8f7 100644 --- a/includes/Product/Hooks.php +++ b/includes/Product/Hooks.php @@ -34,10 +34,9 @@ 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' ] ); // product review action hook add_action( 'comment_notification_recipients', [ $this, 'product_review_notification_recipients' ], 10, 2 ); - // Init Product Cache Class new VendorStoreInfo(); new ProductCache(); @@ -394,6 +393,23 @@ 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() ) || 'auction' === $product->get_type() ) { + 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' ); + } + /** * Filter the recipients of the product review notification. *