Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
webtoffee-git / sample.css
Created April 28, 2026 09:02
CSS to control the appearance of the link - By WebToffee
.wcc-cookie-settings-link {
display: inline-block;
font-size: 14px;
color: #0073aa; /* Adjust to match your brand color */
text-decoration: underline;
cursor: pointer;
margin-top: 10px;
}
.wcc-cookie-settings-link:hover {
color: #005177; /* Darker shade for hover state */
@webtoffee-git
webtoffee-git / sample.html
Created April 28, 2026 09:01
Code to simulate click on the revisit button - By WebToffee
<a href="#" class="wcc-cookie-settings-link" onclick="document.querySelector('.wcc-btn-revisit').click(); return false;">
Cookie Settings
</a>
@webtoffee-git
webtoffee-git / sample.js
Last active April 28, 2026 09:00
Listen for consent and replace the iframe src conditionally - by WebToffee
document.addEventListener("wcc_consent_update", function (eventData) {
const categories = eventData.detail.categories;
const accepted = categories && categories.accepted;
document.querySelectorAll('iframe[data-src*="youtube.com"]').forEach(function (iframe) {
if (accepted && accepted.includes('marketing')) {
iframe.src = iframe.getAttribute('data-src');
} else {
iframe.removeAttribute('src');
}
@webtoffee-git
webtoffee-git / sample.js
Created April 28, 2026 08:37
check whether the user has already consented in a previous session and act accordingly - By WebToffee
document.addEventListener("_wccBannerVisible", function (event) {
const consentData = getWccConsent();
// Check stored analytics consent
if (consentData.categories.analytics === true) {
console.log("Analytics consent is YES (true).");
// Load analytics scripts
} else {
console.log("Analytics consent is NO (false).");
// Do not load analytics scripts
@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.
}