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
Last active November 17, 2021 04:23
Alter address format to suit European standards in WooCommerce PDF Invoice,Packing Slip,Delivery Note plugin
<?php //do not copy this line
add_filter('wf_pklist_alter_shipping_address','wf_pklist_alter_address_fn',10,3);
add_filter('wf_pklist_alter_billing_address','wf_pklist_alter_address_fn',10,3);
add_filter('wf_pklist_alter_shipping_from_address','wf_pklist_alter_address_fn',10,3);
function wf_pklist_alter_address_fn($address, $template_type, $order)
{
$arr=array($address['postcode'], $address['city']);
$address['city']=implode( ", ",$arr);
unset($address['postcode']);
@webtoffee-git
webtoffee-git / functions.php
Last active November 17, 2021 04:27
Display only zip, city in address in shipments using WooCommerce PDF Invoice, Packing Slip, Delivery Note plugin
<?php //do not copy this line
add_filter('wf_pklist_alter_shipping_address','wf_pklist_alter_address_fn',10,3);
add_filter('wf_pklist_alter_billing_address','wf_pklist_alter_address_fn',10,3);
add_filter('wf_pklist_alter_shipping_from_address','wf_pklist_alter_address_fn',10,3);
function wf_pklist_alter_address_fn($address, $template_type, $order)
{
$arr=array($address['postcode'], $address['city']);
$address['city']=implode(", ",$arr);
unset($address['postcode']);
@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
Last active May 3, 2023 12:06
Remove unnecessary product meta data from product table using WooCommerce PDF Invoices, Packing Slips, Delivery Notes and Shipping Labels by WebToffee
add_filter('wf_pklist_modify_meta_data', 'webtoffee_modify_meta_data', 10, 2);
function webtoffee_modify_meta_data($meta) {
// Below are the keys for bundled products and composite products - Change the array keys according to the needs
$keys = array(
'_bundle_group_mode',
'_bundle_cart_key',
'_bundle_weight',
@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
});