WordPress filters

PeachPay supports the following filters for hiding the button on the product, cart, or checkout pages under certain conditions.

  • peachpay_hide_button_on_product_page
  • peachpay_hide_button_on_cart_page
  • peachpay_hide_button_on_checkout_page

Examples

In your WordPress theme code, having the following will hide the button from the product, cart, and checkout pages. You do not have to have all three. Any one of them will work.

add_filter( 'peachpay_hide_button_on_product_page', function () {
return true;
});
add_filter( 'peachpay_hide_button_on_cart_page', function () {
return true;
});
add_filter( 'peachpay_hide_button_on_checkout_page', function () {
return true;
});

You can also hide the button conditionally. In the example below, our fake Item has a price of 101, so the PeachPay button will not show on the checkout page. If the item had a price of 100 or less, the PeachPay button would show.

class Item {
function __construct( int $_cost ) {
$this->cost = $_cost;
}
public $cost = 0;
}
function is_expensive( Item $item ) {
return $item->cost > 100;
}
add_filter( 'peachpay_hide_button_on_checkout_page', function () {
return is_expensive( new Item( 101 ) );
} );