Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
webtoffee-git / functions.php
Created February 13, 2020 05:56
Import product images by WooCommerce additional variation images - WebToffee Product Import Export for WooCommerce
function webtoffee_import_additional_product_variation_images($post_data = array()) {
$key = array_search('woo_variation_gallery_images', array_column($post_data['postmeta'], 'key'));
if (isset($key) && !empty($key) && isset($post_data['postmeta'][$key]['value']) && !empty($post_data['postmeta'][$key]['value'])) {
$imge_urls = explode(',', $post_data['postmeta'][$key]['value']);
if ($imge_urls) {
foreach ($imge_urls as $url) {
$filename = substr(basename($url), 0, -5);
@webtoffee-git
webtoffee-git / functions.php
Created February 13, 2020 06:00
Export product images by WooCommerce additional variation images - WebToffee Product Import Export for WooCommerce
function webtoffee_export_additional_product_variation_images($row = array(), $pid = '', $header_row = array()) {
$key = array_search('"meta:woo_variation_gallery_images"', $header_row);
if (isset($row[$key]) && !empty($row[$key])) {
$attachment_ids = json_decode($row[$key]);
foreach ($attachment_ids as $id) {
$attached_file_url[] = wp_get_attachment_url($id);
}
$row[$key] = implode(',', $attached_file_url);
@webtoffee-git
webtoffee-git / functions.php
Created February 13, 2020 06:01
Modify number of related products using - WebToffee Related Products for WooCommerce
add_filter('wt_related_products_number', function($number){ return 4; } );
@webtoffee-git
webtoffee-git / CookieYes Sample
Created February 13, 2020 06:02
CookieYes Sample
<html>
<head>
This is the head of your page.
<title>Example HTML page</title>
</head>
<body>
This is the body of your page.
</body>
</html>
@webtoffee-git
webtoffee-git / CookieYes Script
Created February 13, 2020 06:03
CookieYes Script
<html>
<head>
This is the head of your page.
<title>Example HTML page</title>
</head>
<body>
This is the body of your page.
.
.
.
@webtoffee-git
webtoffee-git / functions.php
Created February 13, 2020 06:05
Grant permission for additional users roles to export WooCommerce contents - WebToffee Import Export plugins
add_filter('hf_user_permission_roles', 'add_additional_user_role', 10, 1);
function add_additional_user_role($wf_roles) {
array_push($wf_roles, 'current-role-slug');
return $wf_roles;
}
@webtoffee-git
webtoffee-git / functions.php
Created February 13, 2020 06:06
Check WooCommerce plugin is installed and activated or not
/**
* Check woo-commerce plugin is installed and activated or not.
* @return bool
*/
if ( ! function_exists( 'is_woocommerce_activated' ) ) {
@webtoffee-git
webtoffee-git / functions.php
Last active December 9, 2022 14:10
Add more scripts to the default script blocker list using WebToffee GDPR Cookie Consent plugin
function scripts_list() {
$scripts = array(
array(
'id' => 'googletranslator',
'label' => 'GoogleTranslator',
'key' => array('translate.google.com/translate_a/element.js'),
'category' => 'analytics',
'status' => 'yes'
),
);
@webtoffee-git
webtoffee-git / functions.php
Created February 13, 2020 06:08
Hide Email from shipping label using - WooCommerce PDF Invoices, Packing Slips, Delivery Notes & Shipping Labels by WebToffee
//Hide email
add_filter('wf_alter_billing_email', 'wt_alter_billing_email', 10,2);
function wt_alter_billing_email($email, $order_id){
$email = '';
return $email;
}
@webtoffee-git
webtoffee-git / functions.php
Created February 13, 2020 06:09
Hide phone number from shipping label using - WooCommerce PDF Invoices, Packing Slips, Delivery Notes & Shipping Labels by WebToffee
//Hide phone number
add_filter('wf_alter_billing_phone_number', 'wt_alter_billing_phone_number', 10,2);
function wt_alter_billing_phone_number($number, $order_id){
$number = '';
return $number;
}