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-req-nz.php
Last active July 2, 2020 05:20
[WooCommerce 3.0] make NZ region compulsory in checkout page
add_filter( 'woocommerce_billing_fields', 'woo_filter_state_billing', 10, 1 );
add_filter( 'woocommerce_shipping_fields', 'woo_filter_state_shipping', 10, 1 );
function woo_filter_state_billing( $address_fields ) {
$address_fields['billing_state']['required'] = true;
return $address_fields;
}
function woo_filter_state_shipping( $address_fields ) {
$address_fields['shipping_state']['required'] = true;
@rynaldos-zz
rynaldos-zz / wc-pnef.php
Created July 21, 2017 08:51
[WooCommerce 3.0] add phone extension field to checkout page
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
$fields['billing']['billing_phone_ext'] = array(
'label' => __('Phone ext', 'woocommerce'),
'placeholder' => _x('Phone ext', 'placeholder', 'woocommerce'),
'required' => false,
'priority' => 105,
'class' => array('form-row-last'),
'clear' => true
@rynaldos-zz
rynaldos-zz / wcc-ap-php
Last active September 20, 2021 23:53
[WooCommerce 3.0] show categories / links above product title in shop / archive page
add_action( 'woocommerce_before_shop_loop_item_title', 'add_category_title', 25);
function add_category_title()
{
global $product;
$product_cats = wp_get_post_terms($product->get_id(), 'product_cat');
$count = count($product_cats);
foreach($product_cats as $key => $cat)
{
echo
'<span class="wcc_category_title">
@rynaldos-zz
rynaldos-zz / gist:a92386335af0d462d5ce87d70629ddd6
Last active July 18, 2017 09:51
[WooCommerce 3.0.0] add new wishlist icons
1. download the icon you'd like to use (example: http://www.flaticon.com/free-icon/heart_214309#term=heart&page=1&position=18)
2. make sure you download both the 16px and 32px .png for this icon
3. rename the icons as follows:
- heart.png
- [email protected]
4. copy / paste both these icons to the plugin's /assets/images/ folder
5. download this file and paste it to /assets/css/ folder (overwrite the current file): https://www.dropbox.com/s/507kp5q3w0ppe1p/woocommerce-wishlists.css?dl=1
6. download this file and paste it to /classes/ folder (overwrite the current file): https://www.dropbox.com/s/kj4j0fxzeqjznl8/class-wc-wishlists-admin-settings.php?dl=1
@rynaldos-zz
rynaldos-zz / wc-cc-single-pages.php
Last active July 2, 2020 05:20
[WooCommerce 3.0] Show currency converter on single product pages
add_filter( 'woocommerce_get_price_html', 'wc_ninja_add_sc_price_display', 20 );
function wc_ninja_add_sc_price_display( $price ) {
if ( is_product() ) {
echo do_shortcode( '[woocommerce_currency_converter] ' );
}
return $price;
}
//Did this help? Donate me some BTC: 1BEsm8VMkYhSFJ92cvUYwxCtsfsB2rBfiG
@rynaldos-zz
rynaldos-zz / wc-cc-shop-php
Last active September 6, 2017 18:11
[WooCommerce 3.0] Show currency converter on shop / archive page
add_filter( 'woocommerce_get_price_html', 'wc_ninja_add_sc_price_display', 20 );
function wc_ninja_add_sc_price_display( $price ) {
echo do_shortcode( '[woocommerce_currency_converter] ' );
return $price;
}
@rynaldos-zz
rynaldos-zz / wc-add-nire.php
Last active July 2, 2020 05:21
[WooCommerce 3.0] Add Northern Ireland to shipping zones
// https://gist.github.com/WillBrubaker/b9b2415e32a19833aa9c8b1845f64489
add_filter( 'woocommerce_countries', 'handsome_bearded_guy_add_my_country' );
function handsome_bearded_guy_add_my_country( $countries ) {
$new_countries = array(
'NIRE' => __( 'Northern Ireland', 'woocommerce' ),
);
return array_merge( $countries, $new_countries );
}
@rynaldos-zz
rynaldos-zz / wc_change_datepicker_day.php
Last active May 18, 2017 08:36
[WooCommerce] Change datepicker to show Su - Sa
add_filter( 'wp_footer' , 'rs_change_datepicker_cal', 99 );
function rs_change_datepicker_cal() {
?>
<script>
jQuery(function($){
$.datepicker.regional['en-US'] = {
firstDay: 0
@rynaldos-zz
rynaldos-zz / wc_no-atc-per=product-cat.php
Last active September 20, 2021 23:53
[WooCommerce] Hide "add to cart" button on certain product categories
add_action( 'woocommerce_after_shop_loop_item', 'remove_add_to_cart_buttons', 1 );
function remove_add_to_cart_buttons() {
// replace a_category and another_category with the slugs of the categories you'd like to have the button removed from
if( is_product_category( array( 'a_category', 'another_category'))) {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
}
}
// Did this help? Donate me some BTC: 1BEsm8VMkYhSFJ92cvUYwxCtsfsB2rBfiG
@rynaldos-zz
rynaldos-zz / wc-add-standard-value-surcharge.php
Last active September 5, 2017 17:10
[WooCommerce] Add a standard $ value surcharge to all transactions
add_action( 'woocommerce_cart_calculate_fees','wc_add_surcharge' );
function wc_add_surcharge() {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
$county = array('US');
// change the $fee to set the surcharge to a value to suit
$fee = 1.00;