Skip to content

Instantly share code, notes, and snippets.

@wtmujeebu
wtmujeebu / functions.php
Created April 3, 2018 07:35
Hide [CANCEL] button from subscriber’s account - Webtoffee WooCommerce Subscription
add_filter('hf_view_subscription_actions', 'hf_hide_cancel_action', 10, 2);
function hf_hide_cancel_action($actions, $subscription){
if(isset($actions['cancel'])){
unset($actions['cancel']);
}
return $actions;
}
@wtmujeebu
wtmujeebu / functions.php
Last active June 14, 2018 06:00
Add VAT number to the Shipment documents From Address using WebToffee Print invoice and packing slip plugin
add_filter( 'wf_alter_shipmentlabel_from_address', 'wf_new_shipping_from_address_format',10,3 );
function wf_new_shipping_from_address_format($original_address_format,$order,$from_address)
{
$original_address_format .= '<br/>';
$original_address_format .= 'GSTIN:';
$original_address_format .= '12345676787';
$original_address_format .= '<br/>';
@wtmujeebu
wtmujeebu / functions.php
Created June 14, 2018 06:05
Change Add to cart button text only on shop page - WebToffee WooCommerce Subscription
add_filter('woocommerce_product_add_to_cart_text', 'webtoffee_archive_custom_addtocart_button_text', 10, 2);
function webtoffee_archive_custom_addtocart_button_text($var, $instance)
{
if(is_shop()){
$var = __('Read More', 'woocommerce');
}
return $var;
@wtmujeebu
wtmujeebu / functions.php
Last active June 21, 2018 16:25
Add custom columns into audit table - WebToffee GDPR Cookie Consent Plugin
add_filter('cli_new_columns_to_audit_table', 'wt_add_new_column',10,1);
function wt_add_new_column($table)
{
return $table .= '<th class="cookielawinfo-column-5">'.__('Cookie ID', 'cookie-law-info').'</th>';
}
add_filter('cli_new_column_values_to_audit_table','wt_add_new_value',10,2);
@wtmujeebu
wtmujeebu / functions.php
Created June 14, 2018 06:10
Redirect to custom page after successful purchase - WebToffee WooCommerce Subscriptions
add_action('template_redirect', 'webtoffee_custom_redirect_after_purchase');
function webtoffee_custom_redirect_after_purchase() {
global $wp;
if (is_checkout() && !empty($wp->query_vars['order-received'])) {
wp_redirect('http://www.webtoffee.com/'); // Redirect to your desired page here.
@wtmujeebu
wtmujeebu / functions.php
Created June 14, 2018 06:11
Remove My-Account menu links - WebToffee WooCommerce Subscriptions
add_filter('woocommerce_account_menu_items', 'webtoffee_remove_my_account_links');
function webtoffee_remove_my_account_links($menu_links) {
unset($menu_links['subscriptions']); // Subscriptions
unset($menu_links['payment-methods']); // Payment methods
return $menu_links;
}
@wtmujeebu
wtmujeebu / functions.php
Created June 14, 2018 06:13
Add custom custom role to new members - WebToffee WooCommerce Memberships
add_filter('hf_memberships_new_membership_data', 'webtoffee_assign_role_after_membership');
function webtoffee_assign_role_after_membership($new_membership_data, $user_id_product_id_order_id) {
$theUser = new WP_User($user_id_product_id_order_id['user_id']);
$role = 'mycustomrole'; // string $role = Role name
$theUser->add_role($role);
@wtmujeebu
wtmujeebu / functions.php
Created June 26, 2018 11:11
Make order status completed when an order is placed - WebToffee WooCommerce Subscriptions
add_action( 'woocommerce_order_status_processing', 'processing_to_completed');
function processing_to_completed($order_id){
$order = new WC_Order($order_id);
$order->update_status('completed');
}
@wtmujeebu
wtmujeebu / functions.php
Created June 26, 2018 11:13
Add more columns to Cookie Audit Table - WebToffee GDPR Cookie Consent Plugin
add_filter('cli_new_columns_to_audit_table','cli_add_new_columns',10,1);
function cli_add_new_columns($table)
{
$table .= '<th class="cookielawinfo-column-5">'.__('Cookie ID', 'cookie-law-info').'</th>';
$table .= '<th class="cookielawinfo-column-6">'.__('Cookie Sensitivity', 'cookie-law-info').'</th>';
return $table;
}
add_filter('cli_new_column_values_to_audit_table','cli_add_value_to_new_columns',10,2);
@wtmujeebu
wtmujeebu / functions.php
Last active June 28, 2018 11:57
Hide user available actions from my-account view subscription page - WebToffee WooCommerce Subscription
add_filter('hf_view_subscription_actions', 'disable_myacc_user_actions', 10, 2);
function disable_myacc_user_actions($actions, $subscription) {
// unset($actions['cancel']);
// unset($actions['suspend']);
unset($actions['resubscribe']);
return $actions;