Skip to content

Commit

Permalink
update: display Not purchasable notice for own product (#2070)
Browse files Browse the repository at this point in the history
* update: display Not purchasable notice for own product

closes: getdokan/dokan-pro#2782

* update: remove Not purchasable notice for own product in auction product

---------

Co-authored-by: Nurul Umbhiya <[email protected]>
  • Loading branch information
shohag121 and nurul-umbhiya authored Nov 10, 2023
1 parent 0b75acf commit 1ea726c
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions includes/Product/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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.
*
Expand Down

0 comments on commit 1ea726c

Please sign in to comment.