The mbt_buybutton_editor filter allows you to modify or override the default Buy Button editor. Generally this is done on a per-store basis, but it can also be used to globally change all the editors.
The filter provides four arguments:
$output: The overall editor HTML that will be displayed.
$data: The data for the Buy Button that you are editing.
$id: The ID for this Buy Button.
$store: The data for the store that the Buy Button is using. (See Creating and Modifying Stores)
The $data variable will contain whatever data that the Buy Button editor saves 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)
The $id variable is a special identifier that is used to identify the tags for a particular Buy Button. The saving of all Buy Button information is handled automatically, where the sub-variables for each $id are saved into that Buy Button’s data array. For example, if your Buy Button ID happened to be buybutton1 and you wanted to save a custom variable called button_size into your Buy Button data, you would want to add an tag to the editor that had name = “buybutton1[button_size]”. You could then use this data elsewhere to change how the Buy Button displays. (See Customizing Buy Buttons)
Example:
function change_my_buybutton_editor($output, $data, $id, $store) {
if($data[‘type’] == ‘my_store’) {
$editor = ‘‘;
$editor .= ‘‘;
$editor .= ‘
Paste in the product URL for this item.
‘;
}
return $output;
}
add_filter(‘mbt_buybutton_editor’, ‘change_my_buybutton_editor’, 10, 4);