Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
webtoffee-git / sample.js
Created April 28, 2026 08:36
Execute or suppress a script immediately after the user makes a consent choice - By WebToffee
document.addEventListener("wcc_consent_update", function (eventData) {
const categories = eventData.detail.categories;
// Check if the analytics category was accepted
if (categories && categories.accepted && categories.accepted.includes('analytics')) {
console.log('Analytics consent: GRANTED');
// Initialize your analytics script here
} else {
console.log('Analytics consent: DENIED');
// Suppress or remove your analytics script here
@webtoffee-git
webtoffee-git / functions.php
Created April 28, 2026 04:13
Code snippet to recalculate the order totals automatically during import - by Webtoffee (Order Import Export for WooCommerce)
<?php // Do not copy this line of code
/**
* Re-enable WooCommerce order total recalculation during WT Import Export order import.
*
* This ensures WooCommerce rebuilds the internal tax and totals structure
* for imported orders so that third-party invoice and reporting plugins
* display the correct tax labels and subtotal values.
*
* @param WC_Order $order The order object being prepared for insertion.
* @param array $data Raw import data.
@webtoffee-git
webtoffee-git / functions.php
Created April 1, 2026 07:36
Replace “Buy X Get X/Y” with custom text in the Smart Coupons Basic plugin - By WebToffee (Smart Coupon Basic)
<?php //Do not copy this line of code
add_filter( 'wt_smart_coupon_meta_data', function ( $coupon_data, $coupon ) {
$coupon_id = isset( $coupon_data['coupon_id'] ) ? (int) $coupon_data['coupon_id'] : 0;
if ( ! $coupon_id || ! is_a( $coupon, 'WC_Coupon' ) ) {
return $coupon_data;
}
if ( 'wbte_sc_bogo' === $coupon->get_discount_type() ) {
$coupon_data['coupon_type'] = __( 'Redeem Now', 'wt-smart-coupons-for-woocommerce' );
}
return $coupon_data;
@webtoffee-git
webtoffee-git / functions.php
Created March 19, 2026 12:05
Code to Geotarget Consent Banner - WebToffee( GDPR Cookie consent)
<?php //Do not copy this line of code
//Change the country code to target the appropriate country
add_filter('wcc_ccpa_allowed_regions',array('CA','CO'));
@webtoffee-git
webtoffee-git / functions.php
Last active February 18, 2026 09:24
Code snippet to enables Meta-compatible checkout URLs for WooCommerce using WebToffee Product Feed - By WebToffee
<?php //Do not copy this line of code
add_filter( 'wt_feed_facebook_product_checkout_link', 'wbfte_product_feed_change_checkout_url', 10, 2 );
/**
* Modify the checkout URL for Facebook product feeds.
*
* @param string $checkout_url The original checkout URL.
* @param WC_Product $product The product object.
*
* @return string Modified checkout URL.
*/
@webtoffee-git
webtoffee-git / functions.php
Created January 13, 2026 08:44
Customize wishlist table heading text in WooCommerce - By WebToffee (Wishlist for WooCommerce)
<?php //Do not copy this line of code
add_filter('wishlist_table_heading','wbte_gc_change_wishlist_title_description',10,1);
function wbte_gc_change_wishlist_title_description($title){
return 'Products added to favourites'; //add your custom title here.
}
@webtoffee-git
webtoffee-git / functions.php
Created December 23, 2025 09:03
Re-enable admin module in WebToffee import export plugins - By WebToffee( Import export plugin for WooCommerce)
<?php //Do not copy this line of code
add_action('admin_init', 'wt_ier_alter_admin_module_status');
if (!function_exists('wt_ier_alter_admin_module_status')) {
function wt_ier_alter_admin_module_status() {
$module = get_option('wt_iew_admin_modules');
if (!empty($module) && is_array($module)) {
foreach ($module as $mkey => $value) {
if ($value == 0) {
@webtoffee-git
webtoffee-git / functions.php
Created December 18, 2025 09:34
Code to bulk download packing slip - By WebToffee
<?php //Do not copy this line of code
add_filter('wt_print_bulk_actions', 'add_bulk_download_packinglist_buttons');
function add_bulk_download_packinglist_buttons($actions) {
$actions['download_packinglist'] = __('Download Packing slip', 'print-invoices-packing-slip-labels-for-woocommerce');
return $actions;
}
@webtoffee-git
webtoffee-git / functions.php
Created December 15, 2025 10:10
Code snippet to automatically add prefix to product IDs - By WebToffee( Product feed for WooCommerce Basic)
<?php // Do not copy this line of code
/**
* Prefix product ID in feed output.
*
* @param string|int $product_id Product ID being processed.
* @param WC_Product $product Product object.
*
* @return string|int Modified product ID.
*/
function wbtfe_product_feed_alter_product_id( $product_id, $product ) {
@webtoffee-git
webtoffee-git / functions.php
Created December 9, 2025 11:07
Custom code snippet to include subtotal, Shipping amount, Cart discount, Order discount, Fee, Order total and payment method in the QR code - By WebToffee
<?php //Do not copy this line of code
add_filter("wf_pklist_alter_find_replace_in_qrcode", "add_order_details_to_qrcode_currency_code", 10, 6);
function add_order_details_to_qrcode_currency_code($find_replace_in_qrcode, $template_type, $order, $box_packing, $order_package, $custom_qr_details) {
if (!is_a($order, 'WC_Order')) {
return $find_replace_in_qrcode;
}
$currency_code = $order->get_currency();