Skip to content

Instantly share code, notes, and snippets.

View rynaldos-zz's full-sized avatar

Rynaldo rynaldos-zz

View GitHub Profile
@rynaldos-zz
rynaldos-zz / wc-sf-hide-sidebar-make-full.php
Last active February 3, 2017 07:44
[WooCommerce | Storefront] Hide the sidebar on all pages (except for the product page) and make content section full-width
// remove the sidebar everywhere except for products page
function remove_storefront_sidebar() {
if ( ! is_product() ) {
remove_action( 'storefront_sidebar', 'storefront_get_sidebar', 10 );
}
}
add_action( 'get_header', 'remove_storefront_sidebar' );
@rynaldos-zz
rynaldos-zz / add-ane-shipping-methods.php
Last active March 23, 2021 17:44
[WooCommerce] Add the Shipping method to advanced notifications emails
// Place the following code in your theme's functions.php file to add the shipping method to ALL emails
add_action( 'woocommerce_email_after_order_table', 'wc_add_shipping_method_to_emails', 15, 2 );
function wc_add_shipping_method_to_emails( $order, $is_admin_email ) {
echo '<p><strong>Shipping Method:</strong> ' . $order->get_shipping_method() . '</p>';
}
// Place the following code in your theme's functions.php file to add the shipping method to ADMIN emails only
add_action( 'woocommerce_email_after_order_table', 'wc_add_shipping_method_to_admin_emails', 15, 2 );
@rynaldos-zz
rynaldos-zz / unset-sku-pip.php
Last active February 3, 2017 07:39
[WooCommerce] Unset the SKU in PIP (Print Invoices & Packing lists)
add_filter( 'wc_pip_document_table_headers', 'sv_wc_pip_document_unset_sku', 200, 1 );
add_filter( 'wc_pip_document_table_row_item_data', 'sv_wc_pip_document_unset_sku', 200, 1 );
function sv_wc_pip_document_unset_sku( $row ) {
unset( $row['sku'] );
return $row;
}
@rynaldos-zz
rynaldos-zz / continue-shopping-redirect-link.php
Last active February 3, 2017 07:37
[WooCommerce] Replace the Continue shopping button link (shop page)
@rynaldos-zz
rynaldos-zz / functions.php
Created January 6, 2017 10:17 — forked from mikejolley/functions.php
WooCommerce - Split shipping class items into a new package and limit shipping methods
/**
* This function loops over cart items, and moves any item with shipping class 'special-class' into a new package.
* The new package in this example only takes flat rate shipping.
*/
function split_special_shipping_class_items( $packages ) {
$found_item = false;
$special_class = 'special-class'; // edit this with the slug of your shippig class
$new_package = current( $packages );
$new_package['contents'] = array();
$new_package['contents_cost'] = 0;
@rynaldos-zz
rynaldos-zz / nohide-free-lp.php
Last active February 3, 2017 13:37
[WooCommerce] Hide all shipping methods except for Free shipping & Local pickup methods
function hide_shipping_when_free_is_available( $rates, $package ) {
$new_rates = array();
foreach ( $rates as $rate_id => $rate ) {
// Only modify rates if free_shipping is present.
if ( 'free_shipping' === $rate->method_id ) {
$new_rates[ $rate_id ] = $rate;
break;
}
}
@rynaldos-zz
rynaldos-zz / wc-redirect-cus-role-home.php
Created February 3, 2017 07:34
[WooCommerce] Redirect users from my-account page (based on role)
add_filter('woocommerce_login_redirect', 'wc_login_redirect', 10, 2 );
function wc_login_redirect( $redirect_to, $user ) {
$role = $user->roles[0];
$myaccount = get_permalink( wc_get_page_id( 'myaccount' ) );
if( $role == 'customer' ) {
$redirect_to = home_url();
}
return $redirect_to;
}
@rynaldos-zz
rynaldos-zz / no-weights-dimensions.php
Created February 6, 2017 10:48
[WooCommerce] Hide weight / dimensions in single product's additional information tab
add_filter( 'wc_product_enable_dimensions_display', '__return_false' );
@rynaldos-zz
rynaldos-zz / inc-var-threshold.php
Created February 10, 2017 08:26
[WooCommerce] Increase variations threshold to 50
add_filter( 'woocommerce_ajax_variation_threshold', 'wc_ninja_ajax_threshold' );
function wc_ninja_ajax_threshold() {
return 50;
}
@rynaldos-zz
rynaldos-zz / pip-invoice-email-completed.php
Created February 16, 2017 11:19
[WooCommerce | Print Invoice & Packing slips] Only send invoice when order is completed
add_filter( 'wc_pip_invoice_email_order_status_change_trigger_actions', 'woo_custom_invoice_status', 10, 2 );
function woo_custom_invoice_status( $actions, $email_class ) {
$actions = array(
'woocommerce_order_status_failed_to_completed_notification',
'woocommerce_order_status_pending_to_completed_notification',
'woocommerce_order_status_processing_to_completed',
);
return $actions;
}