There are two primary ways of modifying how Buy Buttons display, the mbt_filter_buybutton_data filter, which allows you to temporarily modify the Buy Button’s data before it is displayed, and the mbt_format_buybutton filter, which lets you filter the entire button output.
Filtering Buy Button Data
The mbt_filter_buybutton_data filter works on each Buy Button’s $data variable, and can also provide the $store information that the Buy Button uses if you set the accepted_args variable in add_filter to 2.
The $data variable will contain whatever data that the Buy Button editor saved in it, but the default Buy Button data that is used in the plugin is:
store: The slug of the store that the Buy Button uses. (required)
url: The product page URL that the Buy Button will link to. (required for default display)
display: The display type. Possible values are: book_only, featured, and text_only (required for default display)
Example:
function filter_my_buybutton_data($data, $store) {
if($data[‘store’] == ‘my_store’) {
$data[‘url’] = my_store_custom_url($data[‘url’]);
}
return $data;
}
add_filter(‘mbt_filter_buybutton_data’, ‘filter_my_buybutton_data’, 10, 2);
Overriding Buy Button Output
By default, MyBookTable looks in your currently selected Style Pack for an image to display for your store. To do this it searches for an image called
Using the mbt_format_buybutton filter sometimes requires you to write more code, but it allows you to change any aspect of how your Buy Button displays or even completely replace it with your own output.
Example:
function format_my_buybutton($output, $data, $store) {
if($data[‘store’] == ‘my_store’) {
$output = ““; //Please don’t actually do this
}
return $output;
}
add_filter(‘mbt_format_buybutton’, ‘format_my_buybutton’, 10, 3);