Skip to content

Instantly share code, notes, and snippets.

View bolderelements's full-sized avatar

Erica Dion bolderelements

View GitHub Profile
@bolderelements
bolderelements / wc-show-free-shipping-price.php
Last active September 12, 2019 12:36
Show the Price When Shipping is Free from Third Party Plugin
/**
* Hide the price when shipping is free from third party shipping plugins
* Code snippets should be added to the functions.php file of your child theme
* (Updated for WooCommerce 3.5)
*
* @return string
*/
add_filter( 'woocommerce_cart_shipping_method_full_label', function( $label, $method ) {
// only update for Free shipping methods
$has_cost = 0 < $method->cost;
@bolderelements
bolderelements / wc-hide-shipping-based-on-shipping.php
Last active June 25, 2018 13:27
Hide Free Shipping When Table Rate Option is Available
/**
* Hide all free shipping options when the given shipping option is available to choose
* Code snippets should be added to the functions.php file of your child theme
*
* @return array
*/
function hide_shipping_when_option_is_available( $rates, $package ) {
// set the desired option
$shipping_op = 'betrs_shipping:10-2';
@bolderelements
bolderelements / betrs-add-longest-length-condition.php
Created June 20, 2018 03:43
Add new condition to Table Rate settings page
/**
* Add ability to find and compare the longest length item in Table Rate shipping
* https://codecanyon.net/item/table-rate-shipping-for-woocommerce/3796656?ref=bolderelements
*
* Code should be added to theme's functions.php file
*/
function betrs_add_longest_length_cond( $conditions ) {
// add new option to list
$conditions['longest_length'] = 'Longest Length';
@bolderelements
bolderelements / betrs-add-longest-length-condition.php
Created June 20, 2018 03:43
Add new condition to Table Rate settings page
/**
* Add ability to find and compare the longest length item in Table Rate shipping
* https://codecanyon.net/item/table-rate-shipping-for-woocommerce/3796656?ref=bolderelements
*
* Code should be added to theme's functions.php file
*/
function betrs_add_longest_length_cond( $conditions ) {
// add new option to list
$conditions['longest_length'] = 'Longest Length';
@bolderelements
bolderelements / betrs-modify-order-weight.php
Created May 25, 2018 14:30
Modify the Order Weight for Table Rate Shipping Settings
/*
* Adds additional weight to cover packaging costs.
*
* Requires Table Rate Shipping 4.2+
*/
function betrs_add_packaging_weight( $calculated_totals, $items ){
// weight to add
$add_weight = 350; // change this value to weight needed
// add weight to calculated totals
@bolderelements
bolderelements / remove-shipping-title.php
Last active November 6, 2020 13:42
Remove WooCommerce Shipping Title
/*
* Removes the title from a shipping option.
* Best to be used when only one shipping option is returned.
*
* Requires WooCommerce 2.1+
*/
function remove_title_from_shipping_label( $full_label, $method ){
return str_replace( $method->get_label() . ': ', "", $full_label );
}
add_filter( 'woocommerce_cart_shipping_method_full_label', 'remove_title_from_shipping_label', 10, 2 );
@bolderelements
bolderelements / betrs-add-img-tag-desc.php
Last active May 29, 2018 15:02
Add IMG to Allowed Description Tags
/*
* Adds the <img> tag to allowed tags in the Description field.
*
* Requires Table Rate Shipping for WooCommerce 4.2+
*/
add_filter( 'betrs_desc_allowed_tags', 'add_new_allowed_tags_betrs', 10, 1 );
function add_new_allowed_tags_betrs( $allowedtags ) {
$allowedtags['img'] = array(
'alt' => true,
@bolderelements
bolderelements / shipping-option-surcharge.php
Created April 17, 2018 19:55
Add $5 handling fee to a specific shipping option
/*
* Adds a $5 shipping surcharge to a specific shipping option.
*
* Requires WooCommerce 3.2+
*/
add_filter( 'woocommerce_package_rates', 'add_shipping_option_base_fee', 10, 2 );
function add_shipping_option_base_fee( $rates, $package ) {
foreach( $rates as $key => $rate ) {
// configure surcharge settings
@bolderelements
bolderelements / shipping-extra-fee-class.php
Last active July 24, 2019 11:29
Add Extra Shipping Fee for Items Based on Class
/*
* Adds a $10 shipping surcharge for all items in the cart
* that are assigned to the 'bulky-items' shipping class.
*
* Requires WooCommerce 3.2+
*/
add_filter( 'woocommerce_package_rates', 'add_shipping_option_base_fee', 10, 2 );
function add_shipping_option_base_fee( $rates, $package ) {
foreach( $rates as $key => $rate ) {
@bolderelements
bolderelements / bepawc-merge-account-tabs.php
Created March 5, 2018 20:27
Combine Favorites and Subscriptions tabs in Bolder Product Alerts for WooCommerce
function bepawc_remove_product_subscriptions( $items ) {
unset( $items['product-subscriptions'] );
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'bepawc_remove_product_subscriptions', 999 );
add_action( 'woocommerce_account_favorite-products_endpoint', array( $be_product_alerts->account->subscriptions, 'display_account_settings' ), 50 );