Skip to content

Commit 5f9e13d

Browse files
committed
Make offer button is disable on discounted product
1 parent fac524e commit 5f9e13d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

public/class-offers-for-woocommerce.php

+24
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ private function __construct() {
108108
add_action('woocommerce_before_single_product', array($this, 'angelleye_ofwc_lightbox_make_offer_form'));
109109
/* Add "Make Offer" product tab on product single view */
110110
add_filter('woocommerce_product_tabs', array($this, 'angelleye_ofwc_add_custom_woocommerce_product_tab'), 9, 1);
111+
add_filter('woocommerce_product_tabs', array($this, 'remove_woocommerce_product_tabs'), 98, 1);
111112

112113
/**
113114
* Add "Make Offer" button code parts - After shop loop item.
@@ -234,6 +235,29 @@ private function __construct() {
234235
}
235236
}
236237

238+
/**
239+
* Remove custom WooCommerce product tabs conditionally.
240+
*
241+
* @since 3.0.5
242+
*
243+
* @param array $tabs The existing product tabs.
244+
* @return array Modified tabs.
245+
*/
246+
public function remove_woocommerce_product_tabs($tabs) {
247+
248+
if (!is_array($tabs)) {
249+
$tabs = [];
250+
}
251+
252+
global $product;
253+
254+
if ($product && $product->is_on_sale()) {
255+
unset($tabs['tab_custom_ofwc_offer']);
256+
}
257+
258+
return $tabs;
259+
}
260+
237261
/**
238262
* Add extra details after add to cart form.
239263
*

0 commit comments

Comments
 (0)