Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
webtoffee-git / functions.php
Created September 23, 2024 09:32
Fix compatibility issue with Curcy Multi Currency plugin on the Gift Card product page - By WebToffee (WebToffee Gift Cards plugin)
<?php //Do no copy this line of code
add_filter('wt_gc_alter_giftcard_predifined_amounts',function($predefined){
if(class_exists('WOOMULTI_CURRENCY_F')){
$curcy_currency_settings = WOOMULTI_CURRENCY_F_Data::get_ins();
$currency_list = $curcy_currency_settings->get_list_currencies();
$current_currency = $curcy_currency_settings->get_current_currency();
$current_currency_rate = floatval( $currency_list[ $current_currency ]['rate'] );
foreach($predefined as $key => $value){
@webtoffee-git
webtoffee-git / functions.php
Last active September 16, 2024 12:44
Compatibility with WOOCS currency switcher with invoice basic plugin - By WebToffee
<?php //Do not copy this line of code
add_filter('wt_pklist_alter_currency_symbol', 'wt_pklist_alter_currency_symbol_fun', 9999, 5);
function wt_pklist_alter_currency_symbol_fun($wc_currency_symbol, $symbols, $user_currency, $order, $price) {
if ( $order instanceof WC_Order ) {
$currency = $order->get_currency();
$symbols = get_woocommerce_currency_symbols();
return $symbols[$currency] ?? $wc_currency_symbol;
}
@webtoffee-git
webtoffee-git / functions.php
Created September 11, 2024 09:33
Code snippet to remove address fields from "Form address" in the Shipping label document - 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_shipping_from_address', 'wt_pklist_alter_from_addr', 10, 3);
function wt_pklist_alter_from_addr($fromaddress, $template_type, $order) {
if ( 'shippinglabel' === $template_type ) {
// Define address fields to remove from the "From" address
$address_fields = [
'address_line1',
'address_line2',
'city',
@webtoffee-git
webtoffee-git / functions.php
Created September 10, 2024 10:09
Code snippet to remove address fields form shipping "Form address" - 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_shipping_from_address', 'wt_pklist_alter_from_addr', 10, 3);
function wt_pklist_alter_from_addr($fromaddress, $template_type, $order) {
// Define address fields to remove from the "From" address
$address_fields = [
'address_line1',
'address_line2',
'city',
'state',
@webtoffee-git
webtoffee-git / functions.php
Created August 29, 2024 08:58
Code to hide add to cart button from related products widget - By Webtoffee (Related Products - Product Recommendations for WooCommerce )
<?php //do not copy this line of code
add_action('wp_footer',function() {
if( class_exists('Custom_Related_Products')) {
?>
<style>
.wt-crp-content-wrapper > .wt_cart_button {
display: none;
}
.wt-related-products > .products > .product > .button.nbo_ajax_add_to_cart {
display: none;
@webtoffee-git
webtoffee-git / functions.php
Created August 28, 2024 08:55
Code for customizing the print and download button labels on the My Account page - By WebToffee (WooCommerce PDF Invoices, Packing Slips and Credit Notes Plugin)
<?php //Do not copy this line of code
add_filter('wt_pklist_alter_document_button_label', 'alter_document_btn_label', 10, 4);
function alter_document_btn_label($label, $action, $where, $template_type) {
if ( 'invoice' === $template_type ) {
// Order details page
if ( 'my_account_order_details' === $where ) {
// Customize the print invoice button on the order details page
if ( 'print' === $action ) {
@webtoffee-git
webtoffee-git / functions.php
Created August 28, 2024 08:53
Code for displaying the parent categories alone in packing slips - By WebToffee ( WooCommerce PDF Invoices, Packing Slips and Credit Notes Plugin )
<?php //Do not copy this line of code
add_filter('wf_pklist_alter_grouping_term_names', 'wt_pklist_group_by_parent_cat_invoice', 10, 4);
function wt_pklist_group_by_parent_cat_invoice($term_name_arr, $product_id, $template_type, $order) {
if ( 'packinglist' === $template_type ) {
$terms = get_the_terms($product_id, 'product_cat');
if ( $terms ) {
$main_category_name = '';
$visited_terms = array();
@webtoffee-git
webtoffee-git / functions.php
Created July 31, 2024 11:13
Code for Displaying Custom Product Names in WooCommerce Invoices for Specific Products and Users - By WebToffee
<?php //Do not copy this line of code
add_filter('wf_pklist_alter_product_name', 'wt_pklist_new_prodct_name_for_user', 10, 5);
function wt_pklist_new_prodct_name_for_user($order_item_name, $template_type, $_product, $order_item, $order) {
$target_product_id = 1186;
$target_user_id = 0;
if ( 'invoice' === $template_type && is_object($_product) && is_object($order) ) {
$product_id = $_product->get_id();
$user_id = $order->get_user_id();
@webtoffee-git
webtoffee-git / functions.php
Created July 24, 2024 11:48
Code to skip the order with status Pending payment from generating sequential order number - By WebToffee (Sequential order number for WooCommerce)
<?php //Do not copy this line of code
add_filter('wt_sequential_is_draft_order', 'wt_sequential_skip_pending_order',10,2);
function wt_sequential_skip_pending_order($is_draft_order, $order){
if(!$is_draft_order && ('pending'=== $order->get_status())){
$is_draft_order = true;
}
return $is_draft_order;
}
@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');