Skip to content

Instantly share code, notes, and snippets.

@aadityajs
aadityajs / WooCommerce - Malaysia states.php
Last active January 2, 2016 02:18 — forked from mikejolley/gist:3123855
WooCommerce - Malaysia states
<?php
/**
* Code goes in functions.php or a custom plugin.
*/
add_filter( 'woocommerce_states', 'malaysia_woocommerce_states' );
function malaysia_woocommerce_states( $states ) {
$states['MY'] = array(
'JHR' => __('Johor', 'woocommerce') ,
@aadityajs
aadityajs / WooCommerce - Set default state country for checkout.php
Last active January 2, 2016 02:19 — forked from mikejolley/gist:2974310
WooCommerce - Set default state/country for checkout
<?php
/**
* Manipulate default state and countries
*
* As always, code goes in your theme functions.php file
*/
add_filter( 'default_checkout_country', 'change_default_checkout_country' );
add_filter( 'default_checkout_state', 'change_default_checkout_state' );
function change_default_checkout_country() {
@aadityajs
aadityajs / WooCommerce - Show number of items in cart and total.php
Last active January 2, 2016 02:19
WooCommerce - Show number of items in cart and total
<?php global $woocommerce; ?>
<a class="cart-contents" href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="<?php _e('View your shopping cart', 'woothemes'); ?>"><?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?> - <?php echo $woocommerce->cart->get_cart_total(); ?></a>
@aadityajs
aadityajs / WooCommerce - Change the placeholder image.php
Last active January 2, 2016 02:19 — forked from mikejolley/gist:1967071
WooCommerce - Change the placeholder image
<?php
/*
* goes in theme functions.php or a custom plugin. Replace the image filename/path with your own :)
*
**/
add_filter('woocommerce_placeholder_img_src', 'custom_woocommerce_placeholder_img_src');
function custom_woocommerce_placeholder_img_src( $src ) {
$upload_dir = wp_upload_dir();
<?php
/**
* Plugin Name: Multiple Roles per User
* Description: Allows anyone who can edit users to set multiple roles per user. In a default WordPress environment that wouldn't have much of an effect, since the user would have the privileges of the top-privileged role that you assign to him. But if you have custom roles with custom privileges, this might be helpful.
* Version: 1
* Author: nikolov.tmw
* Author URI: http://paiyakdev.com/
* License: GPL2
*/
/*