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 / sample.only
Created February 17, 2017 18:30
[WooCommerce advanced notifications] Include payments / shipping type in email
<?php
/**
* New order email
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// allowed tags for escaping
$allowed_tags = array(
@rynaldos-zz
rynaldos-zz / wc-hide-cats-archive-page.php
Last active March 7, 2021 00:10
[WooCommerce] Remove categories from shop and other pages
add_filter( 'get_terms', 'get_subcategory_terms', 10, 3 );
function get_subcategory_terms( $terms, $taxonomies, $args ) {
$new_terms = array();
// if a product category and on the shop page
// to hide from shop page, replace is_page('YOUR_PAGE_SLUG') with is_shop()
if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() && is_page('YOUR_PAGE_SLUG') ) {
foreach ( $terms as $key => $term ) {
if ( ! in_array( $term->slug, array( 'woo' ) ) ) {
$new_terms[] = $term;
@rynaldos-zz
rynaldos-zz / wc-custom-no-shipping-methods.php
Created February 24, 2017 11:13
[WooCommerce] Change the "no shipping methods available" message
add_filter( 'woocommerce_no_shipping_available_html', 'my_custom_no_shipping_message' );
add_filter( 'woocommerce_cart_no_shipping_available_html', 'my_custom_no_shipping_message' );
function my_custom_no_shipping_message( $message ) {
return __( 'your_custom_message_goes_here' );
}
@rynaldos-zz
rynaldos-zz / wc-nocoupon-checkout.php
Created March 16, 2017 03:25
[WooCommerce] Removing coupon field from checkout page
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
@rynaldos-zz
rynaldos-zz / wc-no-add-cart.php
Created March 16, 2017 12:15
[WooCommerce] Remove the "added to cart" message
add_filter( 'wc_add_to_cart_message', '__return_empty_string' );
@rynaldos-zz
rynaldos-zz / wc-no-order-again.php
Last active January 14, 2021 13:19
[WooCommerce] Remove the "order again" button
remove_action( 'woocommerce_order_details_after_order_table', 'woocommerce_order_again_button' );
//Did this help? Donate me some BTC: 1BEsm8VMkYhSFJ92cvUYwxCtsfsB2rBfiG
@rynaldos-zz
rynaldos-zz / wc-no-related-products-3.php
Created April 4, 2017 17:27
[WooCommerce 3.0] Remove related products
@rynaldos-zz
rynaldos-zz / wc-custom-purchased-column.php
Last active June 15, 2020 06:26
[WooCommerce 3.0+] Re-instate the "Purchased items" column on orders page
add_filter('manage_edit-shop_order_columns', 'wc_custom_purchased_column');
function wc_custom_purchased_column($columns)
{
$new_array = array();
foreach ($columns as $key => $title) {
if ($key == 'billing_address') {
$new_array['order_items'] = __('Purchased', 'woocommerce');
}
@rynaldos-zz
rynaldos-zz / wc-show-free.php
Last active September 6, 2017 18:00
[WooCommerce 3.0+] Re-instate "Free" instead of 0 value
function my_wc_custom_get_price_html( $price, $product ) {
if ( $product->get_price() == 0 ) {
if ( $product->is_on_sale() && $product->get_regular_price() ) {
$regular_price = wc_get_price_to_display( $product, array( 'qty' => 1, 'price' => $product->get_regular_price() ) );
$price = wc_format_price_range( $regular_price, __( 'Free!', 'woocommerce' ) );
} else {
$price = '<span class="amount">' . __( 'Free!', 'woocommerce' ) . '</span>';
}
}
@rynaldos-zz
rynaldos-zz / remove-pgzoom-theme.php
Last active March 20, 2021 02:45
[WooCommerce 3.0+] Remove product gallery zoom feature
add_action( 'after_setup_theme', 'remove_pgz_theme_support', 100 );
function remove_pgz_theme_support() {
remove_theme_support( 'wc-product-gallery-zoom' );
}