This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Remove the extra number added to the Table Rate option ID | |
* | |
* Requires Table Rate Shipping for WooCommerce 4.2+ | |
*/ | |
add_filter( 'betrs_calculated_table_rate_options', 'betrs_remove_table_id', 10, 1 ); | |
function betrs_remove_table_id( $rates ) { | |
// look through all options created | |
if( is_array( $rates ) && count( $rates ) > 0 ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add ability to check for quantity 3 of a specific shipping class in Table Rate method | |
* Intended for Use with Per Order setups and Method Conditions | |
* https://codecanyon.net/item/table-rate-shipping-for-woocommerce/3796656?ref=bolderelements | |
* | |
* Code should be added to a child theme's functions.php file | |
*/ | |
function betrs_add_class_qty_cond( $conditions ) { | |
// add new option to list | |
$conditions['qty_shipping_class'] = '3 of Shipping Class'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add form field to 'Additional Options' section in the Table of Rates | |
* | |
* @return string | |
*/ | |
function betrs_add_settings_field( $settings ) { | |
// array of shipping provider codes | |
$shipping_carriers = array( | |
'usps' => 'US Postal Service', | |
'fedex' => 'FedEx', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Find the custom column selection when calculating shipping | |
* | |
* @return string | |
*/ | |
function betrs_add_custom_data_shipping_array( $shipping_options, $option, $option_ID, $row_ID ) { | |
// find selected value from table | |
$selection = ( isset( $option['rows'][ $row_ID ]['provider'] ) ) ? sanitize_text_field( $option['rows'][ $row_ID ]['provider'] ) : ''; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Display provider if applicable. | |
* | |
* @return void | |
*/ | |
function betrs_display_provider( $method, $index ) { | |
$meta_data = $method->get_meta_data(); | |
if( isset( $meta_data['provider'] ) ) { | |
echo '<p class="betrs_option_provider">Shipping Provider: ' . stripslashes( sanitize_text_field( $meta_data['provider'] ) ) . '</div>'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Save form field from custom column in the Table of Rates | |
* | |
* @return string | |
*/ | |
function betrs_save_column_data( $save_data, $option_ID, $row_ID ) { | |
// sanitize arguments | |
$option_ID = intval( $option_ID ); | |
$row_ID = intval( $row_ID ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add form field to custom column in the Table of Rates | |
* | |
* @return string | |
*/ | |
function betrs_add_column_data( $content, $item ) { | |
// find previously saved value | |
$saved = ( isset( $item['provider'] ) ) ? sanitize_text_field( $item['provider'] ) : ''; | |
// array of shipping providers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add a column to the Table of Rates | |
* | |
* @return array | |
*/ | |
function betrs_add_column( $columns ) { | |
// temporarily unset the last column (sort) | |
unset( $columns['sort'] ); | |
// setup new column |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add tax subtext to Fees line | |
* Code snippets should be added to the functions.php file of your child theme | |
* | |
* @return string | |
*/ | |
add_filter( 'woocommerce_cart_totals_fee_html', 'add_tax_subtext_on_fees', 10, 2 ); | |
function add_tax_subtext_on_fees( $cart_totals_fee_html, $fee ) { | |
if( $fee->taxable ) { |
NewerOlder