Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
webtoffee-git / basfile.html
Created February 13, 2020 05:43
CookieYes block script/cookies based on consent - www.cookieyes.com
<script async data-cookieyes="cookieyes-analytics" src="https://www.googletagmanager.com/gtag/js?id=UA-144842869-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-144842869-1');
</script>
@webtoffee-git
webtoffee-git / basfile.html
Created February 13, 2020 05:44
CookieYes render custom script based on consent - www.cookieyes.com
<script>
function getCookie(name) {
var re = new RegExp(name + "=([^;]+)");
var value = re.exec(document.cookie);
return (value != null) ? unescape(value[1]) : 'no';
}
if (getCookie('cky-consent') == 'yes' && getCookie('cookieyes-analytics') == 'yes') {
@webtoffee-git
webtoffee-git / functions.php
Created February 13, 2020 05:46
Modify WooCommerce states
/**
* Add or modify WooCommerce States
*/
add_filter( 'woocommerce_states', 'webtoffee_woocommerce_states' );
function webtoffee_woocommerce_states( $states ) {
$states['XX'] = array(
'XX1' => 'State 1',
@webtoffee-git
webtoffee-git / functions.php
Created February 13, 2020 05:47
WooCommerce restrict only Shipping State for selected country
add_action( 'wp_footer', 'webtoffee_checkout_shipping_filter_it_states' );
function webtoffee_checkout_shipping_filter_it_states() {
if ( ! is_checkout() ) {
return;
}
?>
<script>
jQuery(document).ready(function($) {
@webtoffee-git
webtoffee-git / functions.php
Created February 13, 2020 05:48
WooCommerce restrict only Shipping State for selected country
add_action( 'wp_footer', 'webtoffee_checkout_shipping_filter_it_states' );
function webtoffee_checkout_shipping_filter_it_states() {
if ( ! is_checkout() ) {
return;
}
?>
<script>
jQuery(document).ready(function($) {
@webtoffee-git
webtoffee-git / functions.php
Last active February 13, 2020 05:49
Send custom mail content for new users while import - using WebToffee user import export plugin
add_filter('wt_user_registration_email', 'wt_user_registration_email_callback');
function wt_user_registration_email_callback($mail_attrs) {
//$mail_attrs['body']
$mail_attrs['body'] = 'Custom email body';
return $mail_attrs;
}
@webtoffee-git
webtoffee-git / functions.php
Last active June 8, 2022 11:42
Set email alert on successful cron import using Product Import Export for WooCommerce by WebToffee
function wt_pipe_cron_ended(){
$email = 'asd@example.org, ert@example.org';
wp_mail( $email, "Product Auto Import Export", 'Product scheduled import completed.' );
}
add_action('wt_ier_scheduled_action_finished', 'wt_pipe_cron_ended');
@webtoffee-git
webtoffee-git / functions.php
Created February 13, 2020 05:52
Import CSV from multiple URLs using Product Import Export for WooCommerce by WebToffee
function wt_multi_csv_url_import_array(){
return array(
'http://example.com/pro/url_test/Sample%20Products.csv',
'http://example.com/pro/url_test/Product_WooCommerce_Sample_CSV.csv'
);
}
add_filter('hf_multi_csv_url_import_array','wt_multi_csv_url_import_array');
@webtoffee-git
webtoffee-git / header.php
Created February 13, 2020 05:53
GDPR Compliance for Google Tag Manager - WebToffee GDPR Cookie consent plugin
<script>
function CookieLawInfo_Accept_Callback()
{
if (CLI.consent.non_necessary)
{
dataLayer.push({'event': 'cli_cookieconsent_non_necessary'});
}
if (CLI.consent.analytics)
{
dataLayer.push({'event': 'cli_cookieconsent_analytics'});
@webtoffee-git
webtoffee-git / header.php
Created February 13, 2020 05:54
Javascript helper function for script blocking( Hotjar , Google Analytics ) - using WebToffee GDPR Cookie Consent
<script>
function CookieLawInfo_Accept_Callback()
{
if (CLI.consent.non_necessary)
{
// Hotjar Analytics
(function (h, o, t, j, a, r) {
h.hj = h.hj || function () {
(h.hj.q = h.hj.q || []).push(arguments)
};