Skip to content

Instantly share code, notes, and snippets.

@bekarice
bekarice / wc-mpc-measurement-label.php
Last active February 4, 2019 23:18
Measurement Price Calculator Translate Labels
function sv_mpc_measurement_label( $label ) {
return apply_filters( 'translate_string', $label, 'woocommerce-measurement-price-calculator', $label);
}
add_filter( 'wc_measurement_price_calculator_label', 'sv_mpc_measurement_label' );
add_filter( 'wc_measurement_price_calculator_unit_label', 'sv_mpc_measurement_label' );
@bekarice
bekarice / tab-manager-third-party-tabs.php
Last active November 17, 2018 22:11
Tab Manager Third Party Compat
function third_party_tab( $tabs ) {
global $product;
$some_check = $product ? third_party_check( $product->id ) : null;
if ( $product && ! $some_check ) {
return $tabs;
}
$tabs['third_party_tab'] = array(
@bekarice
bekarice / heading-shortcode.php
Last active February 4, 2019 23:18
Shortcode: Create Headings with anchor + link icon
<?php // only copy this line if needed!
// REQUIRES PHP 5.3+
/**
* Create a shortcode to insert a header with an anchor icon.
* Use [heading size="2" id="anchor"]Heading[/heading]
*
* Recommended: Add prefix / change shortcode name to avoid conflicts
*/
@bekarice
bekarice / remove-wc-sorting-options.php
Last active February 4, 2019 23:18
Remove WooCommerce Sorting Options
/**
* Reference post: http://www.skyverge.com/blog/remove-woocommerce-default-sorting-option/
*/
/**
* Removes "Default Sorting" from the shop template
*
* Can be used to unset other keys / sorting options instead
* Ref: https://github.com/woothemes/woocommerce/blob/master/includes/wc-template-functions.php#L654
*/
@bekarice
bekarice / rename-coupon-cart-field.php
Last active February 4, 2019 23:18
Rename coupon field in WooCommerce cart
// rename the coupon field on the cart page
function woocommerce_rename_coupon_field_on_cart( $translated_text, $text, $text_domain ) {
// bail if not modifying frontend woocommerce text
if ( is_admin() || 'woocommerce' !== $text_domain ) {
return $translated_text;
}
if ( 'Apply Coupon' === $text ) {
$translated_text = 'Apply Promo Code';
@bekarice
bekarice / add-wc-order-status.php
Last active September 5, 2019 08:40
Add WooCommerce 2.2 Order Status
<?php // only copy if needed!
/**
* Register new status
* Tutorial: http://www.sellwithwp.com/woocommerce-custom-order-status-2/
**/
function register_awaiting_shipment_order_status() {
register_post_status( 'wc-awaiting-shipment', array(
'label' => 'Awaiting shipment',
'public' => true,
@bekarice
bekarice / add-multiple-wc-order-statuses.php
Last active June 11, 2020 13:15
Register multiple WooCommerce 2.2+ order statuses
/**
* Register new statuses - add an array for each status
* Tutorial: http://www.sellwithwp.com/woocommerce-custom-order-status-2/
**/
function register_new_wc_order_statuses() {
register_post_status( 'wc-awaiting-shipment', array(
'label' => 'Awaiting shipment',
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
@bekarice
bekarice / wc-replace-coupon-code-with-message.php
Last active February 4, 2019 23:17
Replace Coupon: CODE with generic message in WooCommerce
// Hides the coupon code applied by replacing it with a generic message
add_filter( 'woocommerce_cart_totals_coupon_label', 'skyverge_change_coupon_label' );
function skyverge_change_coupon_label() {
echo 'Discount Applied';
// Change this text to whatever you want
}
@bekarice
bekarice / wc-remove-skus-product-page.php
Last active February 4, 2019 23:17
Remove SKUs from WooCommerce product page display
// Remove SKUs from frontend product pages for admin-only use
function skyverge_unhook_product_page_skus( $enabled ) {
// Only remove SKUs if we're not in the admin & on a product page
if ( ! is_admin() && is_product() ) {
return false;
}
return $enabled;
}
add_filter( 'wc_product_sku_enabled', 'skyverge_unhook_product_page_skus' );
@bekarice
bekarice / wc-social-login-link-shortcode.php
Last active February 4, 2019 23:17
Add WooCommerce Social Login "Link Account" buttons shortcode