Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
webtoffee-git / functions.php
Created January 30, 2020 05:54
Alter packing slip item quantity using WooCommerce PDF Invoices, Packing Slips, Delivery Notes and Shipping Labels plugin
add_filter('wf_pklist_alter_package_item_quantiy', 'alter_packing_slip_quantiy', 10 , 5);
function alter_packing_slip_quantiy($item_quantity, $template_type, $_product, $item, $order)
{
if($template_type=='packinglist')
{
if($item_quantity>1)
{
$item_quantity = '<span style="color:red;">'.$item_quantity.'</span>';
}
}
@webtoffee-git
webtoffee-git / functions.php
Created February 13, 2020 05:19
Change express checkout button using Paypal express checkout for WooCommerce by WebToffee
add_filter('eh_paypal_express_checkout_button', 'webtoffee_paypal_express_checkout_button', 10, 1);
function webtoffee_paypal_express_checkout_button($url) {
$url = 'https://www.paypalobjects.com/webstatic/en_US/i/buttons/checkout-logo-medium.png'; // change this URL with the desired image URL
return $url;
}
@webtoffee-git
webtoffee-git / functions.php
Created February 13, 2020 05:23
Add order status to invoice using WooCommerce PDF Invoices, Packing Slips, Delivery Notes & Shipping Labels by WebToffee
add_filter('wf_pklist_alter_additional_fields', 'webtoffee_add_order_status_in_invoice', 10, 3);
function webtoffee_add_order_status_in_invoice($extra_fields, $template_type, $order) {
$extra_fields['Order status']=$order->get_status();
return $extra_fields;
}
@webtoffee-git
webtoffee-git / functions.php
Created February 13, 2020 05:26
Alter packing slip item quantity using WooCommerce PDF Invoices, Packing Slips, Delivery Notes and Shipping Labels plugin
add_filter('wf_pklist_alter_package_item_quantiy', 'alter_packing_slip_quantiy', 10 , 5);
function alter_packing_slip_quantiy($item_quantity, $template_type, $_product, $item, $order)
{
if($template_type=='packinglist')
{
if($item_quantity>1)
{
$item_quantity = '<span style="color:red;">'.$item_quantity.'</span>';
}
}
@webtoffee-git
webtoffee-git / functions.php
Created February 13, 2020 05:31
Change Order description in Stripe dashboard using WooCommerce Stripe Payment Gateway plugin by WebToffee
add_filter('eh_stripe_charge_description_details', 'webtoffee_stripe_charge_description', 10, 2);
function webtoffee_stripe_charge_description($description, $wc_order) {
$description = '';
foreach ($wc_order->get_items() as $item) {
$description .= $item['name'] . ' * ' . $item['quantity'] . ' | ';
}
return substr_replace($description, "", -2);
}
@webtoffee-git
webtoffee-git / functions.php
Created February 13, 2020 05:32
Modify sorting of related products using WooCommerce Related Product by WebToffee
add_filter('wt_related_products_odrerby', function($odrerby){
return 'date'; // default is 'title' -- see WP Query args for more details
});
add_filter('wt_related_products_odrer', function($odrer){
return 'DESC'; // default is 'ASC' -- see WP Query args for more details
});
@webtoffee-git
webtoffee-git / functions.php
Created February 13, 2020 05:41
Limit number of related products using WooCommerce Related Product by WebToffee
add_filter('wt_related_products_number', function($number){
return 4; // change the number here
});
@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($) {