Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
webtoffee-git / functions.php
Created April 28, 2025 09:18
Modify the font size of the text in the Product Table and Summary Table of the Invoice document - By WebToffee ( WooCommerce PDF Invoices, Packing Slips, Delivery Notes, and Shipping Labels)
<?php //do not copy this line of code
add_filter('wf_pklist_alter_template_html', 'wt_pklist_change_product_table_body_bg_font', 10, 2);
function wt_pklist_change_product_table_body_bg_font($html, $template_type) {
if ('invoice' === $template_type) { // or 'packinglist' if needed
$html .= '<style type="text/css">
.wfte_product_table_head th {
font-size: 18px; /* Font size for header */
}
.wfte_product_table_body td,
@webtoffee-git
webtoffee-git / functions.php
Last active April 28, 2025 08:49
Code to Add Product Weight Below Product Name in Email Template - By WebToffee(WebToffee eCommerce Marketing Automation – Email marketing, Popups, Email customizer)
<?php //Do not copy this line of code
add_action('woocommerce_order_item_meta_end', function($item_id, $item, $order, $plain_text) {
$product = $item->get_product();
if (!$product) return;
$weight = $product->get_weight();
if(!empty($weight)){
echo '<br><b class="wt_product_weight">' . __('Weight:', 'woocommerce') . '</b> ' . ($weight . ' ' . get_option('woocommerce_weight_unit') );
}
}
@webtoffee-git
webtoffee-git / functions.php
Created April 11, 2025 11:33
To alter webp product image size in invoice document for mPDF add-on users - By WebToffee (WooCommerce PDF Invoice, Packing Slips, Delivery Notes and Shipping labels)
<?php //do not copy this line of code
add_filter('wf_pklist_alter_product_table_columns', 'wt_pklist_alter_product_image_size', 10, 5);
add_filter('wf_pklist_alter_package_product_table_columns', 'wt_pklist_alter_product_image_size', 10, 5);
function wt_pklist_alter_product_image_size($product_row_columns, $template_type, $_product, $order_item, $order) {
if ('invoice' === $template_type) {
$image_id = $_product->get_image_id();
if ($image_id) {
$image_url = wp_get_attachment_url($image_id);
@webtoffee-git
webtoffee-git / functions.php
Created April 11, 2025 09:30
To change the Print Invoice button colour in WooCommerce order mail - By WebToffee (WooCommerce PDF Invoice, Packing Slips, Delivery Notes and Shipping labels)
<?php //do not coopy this line of code
add_filter("wt_pklist_alter_style_for_email_button", "wt_pklist_alter_document_button_style_email", 10, 2);
function wt_pklist_alter_document_button_style_email($style_arr, $template_type) {
$style_arr['background'] = '#ff0000'; //Change button background color
$style_arr['border-color'] = '#cc0000'; //Change border color
$style_arr['box-shadow'] = '0 1px 0 #990000'; //Change button shadow
return $style_arr;
}
@webtoffee-git
webtoffee-git / functions.php
Created March 24, 2025 11:44
To hide default related products when using related products shortcode – By WebToffee(Related Products - Create Upsells, Cross-sells, and Product Recommendations for WooCommerce)
<?php //Do not copy this line of code
/**
* Hide default related products when [wt-related-products] shortcode is used
*/
function wt_custom_hide_default_related_products() {
if (is_product()) {
global $post;
if ($post && has_shortcode($post->post_content, 'wt-related-products')) {
// Remove WooCommerce's default related products
remove_action('woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);
@webtoffee-git
webtoffee-git / functions.php
Last active March 6, 2025 04:33
Retrieve Order ID Using _order_number Metadata via WooCommerce REST API - By WebToffee (Sequential Order Number for WooCommerce)
<?php //Do not copy this line of code
/*You can fetch the Order ID based on the _order_number metadata using WooCommerce's REST API. To do this, use the following API endpoint:
wp-json/wc/v3/orders?meta_key=_order_number&meta_value=123
Simply replace 123 with the desired order number to retrieve the corresponding Order ID.*/
add_filter( 'woocommerce_rest_shop_order_object_query', function( $args, $request ) {
if (! empty($request['meta_key'] ) &&! empty( $request['meta_value'] ) ) {
$args ['meta_query'] = array(
array (
@webtoffee-git
webtoffee-git / functions.php
Created February 28, 2025 10:39
Code snippet to ensure compatibility between the Smart Coupons for WooCommerce, Side Cart WooCommerce, and Mercado Pago plugins - By WebToffee( Smart Coupon For WooCommerce Plugin)
//Do not copy this line of code
/**
* Set block checkout values on page load.
*/
add_action( 'wp_head', function() {
?>
<script>
jQuery(document).ready(function($){
setTimeout(() => wbte_set_block_checkout_values(), 100);
@webtoffee-git
webtoffee-git / functions.php
Last active March 3, 2025 04:30
Code to hide the original price and display only the discounted price for the BOGO gift item(Old bogo) - By WebToffee (Smart Coupon For WooCommerce Plugin)
<?php //Do not copy this line of code
add_filter( 'woocommerce_cart_item_subtotal', 'wbte_sc_ctm_alter_cart_item_price', 1001, 2 );
add_filter( 'woocommerce_cart_item_price', function( $price, $cart_item ) {
return wbte_sc_ctm_alter_cart_item_price( $price, $cart_item, false );
}, 11, 2 );
function wbte_sc_ctm_alter_cart_item_price( $price, $cart_item, $is_total = true )
{
$out = $price;
@webtoffee-git
webtoffee-git / functions.php
Created January 15, 2025 11:21
Special character importing issue (accents) - By WebToffee (Product Import Export for WooCommerce)
<?php //Do not include this line of code
add_filter( 'wt_import_csv_parser_keep_bom', '__return_false' );
@webtoffee-git
webtoffee-git / functions.php
Last active January 8, 2025 08:47
This snippet enables multisites using same stripe account compatible with OAuth authentication - By WebToffee (Stripe payment gateway for WooCommerce pro & basic)
<?php //Do not copy this line of code
add_filter("wt_stripe_same_account_for_all_sites", "__return_true");