Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
webtoffee-git / functions.php
Last active August 26, 2025 07:05
Code to retain Sequential number for old orders even after deactivating the plugin - By WebToffee
<?php //Do not copy this line of code
add_filter('woocommerce_order_number', 'wt_show_old_order_number', PHP_INT_MAX, 2);
function wt_show_old_order_number($order_number, $order)
{
if ($order instanceof WC_Order) {
$meta_value = $order->get_meta('_order_number');
if ($meta_value) {
$order_number = $meta_value;
}
@webtoffee-git
webtoffee-git / functions.php
Created August 25, 2025 07:44
Compatibility issue with Gift Card templates on Product page - By WebToffee (WebToffee WooCommerce Gift Cards free version)
<?php //do not copy this line of code
add_action('woocommerce_before_single_product', function(){
if(function_exists('is_product') && is_product() && class_exists('Wbte_Gc_Gift_Card_Free_Common'))
{
global $product;
if(!empty($product)
&& method_exists('Wbte_Gc_Gift_Card_Free_Common', 'is_gift_card_product')
&& method_exists('Wbte_Gc_Gift_Card_Free_Common', 'is_templates_enabled')
&& Wbte_Gc_Gift_Card_Free_Common::is_gift_card_product($product->get_id())
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko; CookieYesbot/1.0; +http://www.cookieyes.com/documentation/cookieyesbot) Chrome/131.0.6778.0 Safari/537.36
@webtoffee-git
webtoffee-git / functions.php
Created June 27, 2025 05:54
Disable Webhook Sleep Delay in Stripe Plugin - By WebToffee ( Stripe Basic plugin )
<?php //do not copy this line of code
add_filter('wtst_webhook_sleep_time', 'set_webhook_sleep_time');
function set_webhook_sleep_time($time) {
return 0;
}
@webtoffee-git
webtoffee-git / Functions.php
Created June 9, 2025 10:00
Code Snippet to override the plugin’s CSS style - By WebToffee(Related products plugin)
<?php> //Do not copy this line of code
add_action('wp_footer',function(){
?>
<style>
.wt-related-products .owl-theme .owl-nav { margin-top: 25px !important; }
</style>
<?php
},10);
@webtoffee-git
webtoffee-git / functions.php
Last active June 9, 2025 09:49
Code to import only certain brands - By WebToffee (Product import export basic)
<?php>//Do not copy this line of code
add_filter('wt_iew_importer_do_import_basic', 'filter_products_by_brand', 1, 4);
function filter_products_by_brand($data_arr, $to_process, $step, $selected_template_data) {
// Define allowed brands (normalized to uppercase and trimmed)
$allowed_brands = array_map('strtoupper', array_map('trim', array('Brand1', 'Brand2', 'Brand3')));
foreach ($data_arr as $key => $product) {
if (isset($product['meta_mapping_fields']['taxonomies']['tax:product_brand'])) {
$raw_brand = $product['meta_mapping_fields']['taxonomies']['tax:product_brand'];
@webtoffee-git
webtoffee-git / functions.php
Created June 3, 2025 09:58
Code to change the related product widget heading from h1 to h3 - By WebToffee (Related products Basic plugin)
<?php> //Do not copy this line of code
add_action('wp_footer', function () {
if (is_product()) {
?>
<script>
jQuery(document).ready(function () {
const container = jQuery('.wt-related-products');
if (container.length > 0) {
const h1 = container.find('.wt-crp-heading');
if (h1.length) {
@webtoffee-git
webtoffee-git / functions.php
Last active June 5, 2025 03:44
Code snippet to hide applied coupons and inapplicable coupons from display - By WebToffee (Smart Coupon Basic)
<?php>//Do not copy this line of code
add_filter( 'wt_smart_coupon_display_invalid_coupons', '__return_false' );
add_filter( 'wt_sc_alter_user_coupons', 'wbte_sc_remove_applied_coupons_from_user_coupons' );
if ( ! function_exists( 'wbte_sc_remove_applied_coupons_from_user_coupons' ) ) {
/**
* Remove applied coupons from user coupons list
*
* @param array $post_ids Array of coupon post IDs.
<?php //Do not copy this line of code
add_action('wp_footer', function () {
if (is_product()) {
?>
<script>
jQuery(document).ready(function () {
const container = jQuery('.wt-related-products');
if (container.length > 0) {
const h2 = container.find('.wt-crp-heading');
if (h2.length) {
@webtoffee-git
webtoffee-git / functions.php
Created May 22, 2025 07:14
Code snippet to hide tax items from invoice document - By WebToffee
<?php> //Do not copy this line of code
add_filter('wf_pklist_alter_template_html', 'wt_remove_tax_items_row_from_invoice', 10, 2);
function wt_remove_tax_items_row_from_invoice( $html, $template_type ) {
if ( $template_type === 'invoice' && strpos( $html, 'data-row-type="wfte_tax_items"' ) !== false ) {
// Only run regex if pattern likely exists
$html = preg_replace(
'/<tr[^>]*data-row-type="wfte_tax_items"[^>]*>.*?<\/tr>/is',
'',
$html
);