Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update: display Not purchasable notice for own product #2070

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@

// 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 @@ -184,11 +183,11 @@
<div class="dokan-store-products-filter-area dokan-clearfix">
<form class="dokan-store-products-ordeby" method="get">
<input type="text" name="product_name" class="product-name-search dokan-store-products-filter-search"
placeholder="<?php esc_attr_e( 'Enter product name', 'dokan-lite' ); ?>" autocomplete="off"

Check warning on line 186 in includes/Product/Hooks.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 3 spaces.
data-store_id="<?php echo esc_attr( $store_id ); ?>">

Check warning on line 187 in includes/Product/Hooks.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 3 spaces.
<div id="dokan-store-products-search-result" class="dokan-ajax-store-products-search-result"></div>
<input type="submit" name="search_store_products" class="search-store-products dokan-btn-theme"
value="<?php esc_attr_e( 'Search', 'dokan-lite' ); ?>">

Check warning on line 190 in includes/Product/Hooks.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 3 spaces.

<?php if ( is_array( $orderby_options['catalogs'] ) && isset( $orderby_options['orderby'] ) ) : ?>
<select name="product_orderby" class="orderby orderby-search"
Expand All @@ -213,7 +212,7 @@
* @return void
*/
public function bulk_product_status_change() {
if ( ! current_user_can( 'dokan_delete_product' ) ) {

Check warning on line 215 in includes/Product/Hooks.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found unknown capability "dokan_delete_product" in function call to current_user_can(). Please check the spelling of the capability. If this is a custom capability, please verify the capability is registered with WordPress via a call to WP_Role(s)->add_cap(). Custom capabilities can be made known to this sniff by setting the "custom_capabilities" property in the PHPCS ruleset.
return;
}

Expand Down Expand Up @@ -269,7 +268,7 @@
* @return void
*/
public function update_category_data_for_bulk_and_quick_edit( $product ) {
if ( ! current_user_can( 'manage_woocommerce' ) ) {

Check warning on line 271 in includes/Product/Hooks.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found unknown capability "manage_woocommerce" in function call to current_user_can(). Please check the spelling of the capability. If this is a custom capability, please verify the capability is registered with WordPress via a call to WP_Role(s)->add_cap(). Custom capabilities can be made known to this sniff by setting the "custom_capabilities" property in the PHPCS ruleset.
return;
}

Expand Down Expand Up @@ -394,6 +393,23 @@
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' );
}

Check failure on line 412 in includes/Product/Hooks.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Whitespace found at end of line
/**
* Filter the recipients of the product review notification.
*
Expand Down
Loading