Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
webtoffee-git / function.php
Created July 18, 2024 12:10
Code to disable the assembly cost option provided by Product Assembly / Gift Wrap / Plugin - By WebToffee (WebToffee WooCommerce Gift Cards)
<?php //Do not copy this line of code
function wt_admin_show_assembly_cost_on_giftcard() {
?>
<script>
jQuery(document).ready(function() {
setTimeout(function() {
if(jQuery('._wt_gc_amounts_field').length){
jQuery('._has_assembly_field').insertAfter('._wt_gc_amounts_field');
jQuery('._disable_assembly_field').insertAfter('._wt_gc_amounts_field');
@webtoffee-git
webtoffee-git / functions.php
Last active July 9, 2024 03:51
Code to delete products from the site - By WebToffee( Product Import and Export plugin)
<?php //Do not copy this line of code
function wt_ier_delete_existing_product_in_certain_category($query_args)
{
$query_args['tax_query'][] = array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array('category1', 'category2', 'category3')
);
return $query_args;
@webtoffee-git
webtoffee-git / functions.php
Created July 5, 2024 10:55
Code to remove email restriction from gift card when sent from admin panel - By WebToffee (WooCommerce Gift Cards)
<?php //Do not copy this line of code
add_filter( 'wt_gc_admin_coupon_set_email_restriction', '__return_false');
@webtoffee-git
webtoffee-git / functions.php
Last active July 5, 2024 10:54
Code to remove email restriction from gift cards - By WebToffee (WooCommerce Gift Cards)
<?php //Do not copy this line of code
add_filter( 'wt_gc_coupon_set_email_restriction', '__return_false');
@webtoffee-git
webtoffee-git / functions.php
Created June 21, 2024 09:29
Code snippet to provide access to user roles other than admin and shop managers - By WebToffee (Export and Import Users and Customers)
<?php //Do not copy this line of code
//Using the snippet, users can provide access to user roles other than admin and shop managers to access the plugin. However, the user role will need to have Wordpress dasboard access.
add_filter('wt_wt_import_export_for_woo_basic_alter_role_access_basic', 'wt_wt_import_export_for_woo_alter_role_access_new', 10, 1);
function wt_wt_import_export_for_woo_alter_role_access_new($roles) {
array_push($roles, 'author'); // Replace the necessary roles here. If more than one role, insert values separated by commas.
return $roles;
}
@webtoffee-git
webtoffee-git / functions.php
Created June 6, 2024 04:28
Code use "id" as the unique "id" for Facebook feed instead of the "sku-id" format - By WebToffee (Product Feed for WooCommerce)
<?php //Do not copy this line of code
add_filter('wt_feed_filter_product_id', 'wt_feed_filter_product_id', 10, 2);
function wt_feed_filter_product_id($sku_id, $product) {
$id = $product->get_id();
return $id;
}
@webtoffee-git
webtoffee-git / functions.php
Created May 28, 2024 10:28
Code to edit the product image size in the packing slip - By WebToffee(WooCommerce PDF Invoices, Packing slips, and Credit notes plugin)
<?php //Do not copy this line of code
add_filter('wf_pklist_add_custom_css','wt_pklist_alter_product_image_col',10,2);
function wt_pklist_alter_product_image_col($custom_css,$template_type)
{
if( 'packinglist' === $template_type )
{
$custom_css.='.wfte_product_image_thumb{ max-width:none !important; max-height:none !important; width:80px !important; }';
}
return $custom_css;
}
@webtoffee-git
webtoffee-git / functions.php
Created May 27, 2024 12:14
Add custom shortcodes to Wordpress emails - By WebToffee( Decorator – WooCommerce email customizer )
<?php //Do not copy this line of code
add_filter('wt_woomail_no_order_body_text','wbtf_add_custom_placeholder_to_user_emails',10,2);
function wbtf_add_custom_placeholder_to_user_emails($body_text, $email) {
if ( is_a( $email->object, 'WP_User' ) ) {
$body_text = str_replace( '{custom_value}', 'Actual data to replace', $body_text ); // Replace placeholder and value here
}
return $body_text;
}
@webtoffee-git
webtoffee-git / functions.php
Created May 27, 2024 12:13
Add custom shortcodes to WooCommerce emails - By WebToffee( Decorator – WooCommerce email customizer )
<?php //Do not copy this line of code
add_filter('wt_woomail_order_body_text','wbtf_add_custom_placeholder_to_order_emails',10,5);
function wbtf_add_custom_placeholder_to_order_emails($body_text, $order, $sent_to_admin, $plain_text, $email) {
if ( is_a( $email->object, 'WC_Order' ) && $order ) {
$body_text = str_replace( '{custom_data}', 'Actual data to replace', $body_text ); // Replace placeholder and value here
}
return $body_text;
}
@webtoffee-git
webtoffee-git / functions.php
Created May 27, 2024 12:11
Display order Id and order number together on the WooCommerce orders page - By WebToffee (Sequential order number for WooCommerce )
<?php //Do not copy this line of code
add_filter('wt_alter_sequence_number', 'wtsn_alter_order_number_formate',10,2);
if(!function_exists('wtsn_alter_order_number_formate')){
function wtsn_alter_order_number_formate($sequential_order_number,$order_id){
if($sequential_order_number){
return 'order number:' . $sequential_order_number . ' order id:' .$order_id;
}else{
return $order_id;
}