Skip to content

Instantly share code, notes, and snippets.

View lmartins's full-sized avatar

Luis Martins lmartins

  • Goodwin Media, Multiweb
  • Portugal
View GitHub Profile
@lmartins
lmartins / functions.php
Last active August 29, 2015 14:08 — forked from studiopress/functions.php
Genesis load Google Fonts
<?php
//* Do NOT include the opening php tag
//* Enqueue Lato Google font
add_action( 'wp_enqueue_scripts', 'sp_load_google_fonts' );
function sp_load_google_fonts() {
wp_enqueue_style( 'google-font-lato', '//fonts.googleapis.com/css?family=Lato:300,700', array(), CHILD_THEME_VERSION );
}
@lmartins
lmartins / functions.php
Last active August 29, 2015 14:08 — forked from kloon/functions.php
Change product variation price range to a simpler "From: " display type.
<?php
// Use WC 2.0 variable price format, now include sale price strikeout
add_filter( 'woocommerce_variable_sale_price_html', 'wc_wc20_variation_price_format', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'wc_wc20_variation_price_format', 10, 2 );
function wc_wc20_variation_price_format( $price, $product ) {
// Main Price
$prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
$price = $prices[0] !== $prices[1] ? sprintf( __( 'From: %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
// Sale Price
$prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) );
@lmartins
lmartins / functions.php
Last active August 29, 2015 14:08 — forked from ChromeOrange/functions.php
Add login link to My Account menu
<?php
/**
* Add login link to my account menu.
*
* Add this to your theme functions file
*/
add_filter( 'wp_nav_menu_items', 'woocommerce_nav_menu_items_login', 10, 2 );
function woocommerce_nav_menu_items_login( $items, $args ) {
if ( get_option('woocommerce_menu_logout_link')=='yes' && strstr($items, get_permalink(woocommerce_get_page_id('myaccount'))) && !is_user_logged_in() )
@lmartins
lmartins / stock.php
Last active August 29, 2015 14:08 — forked from bryceadams/ChangeWooCommerceStockText.php
https://support.woothemes.com/hc/en-us/articles/202845976-How-to-Change-In-Stock-Out-of-Stock-Text There may come a time where you would like change the text displayed on a product's page when it is In Stock or Out of Stock. Simply add the following code to the 'custom functions' area of your functions.php file: You may want to leave out that fi…
<?php
/**
* Change In Stock / Out of Stock Text
*/
add_filter( 'woocommerce_get_availability', 'wcs_custom_get_availability', 1, 2);
function wcs_custom_get_availability( $availability, $_product ) {
// Change In Stock Text
@lmartins
lmartins / functions.php
Created October 20, 2014 18:19 — forked from jameskoster/functions.php
// Remove the product rating display on product loops
// Remove the product rating display on product loops
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );
@lmartins
lmartins / gist:d513aca47948b34b8a66
Last active August 29, 2015 14:07 — forked from billerickson/gist:1717547
Genesis Swap Sidebars
<?php
add_action( 'genesis_after_header', 'be_change_sidebar_order' );
/**
* Swap Primary and Secondary Sidebars on Sidebar-Sidebar-Content
*
* @author Bill Erickson
* @link http://www.billerickson.net/switch-genesis-sidebars/
*/
function be_change_sidebar_order() {
@lmartins
lmartins / functions.php
Last active August 29, 2015 14:07 — forked from srikat/functions.php
Add body css class to all pages except the homepage
<?php
//* Do NOT include the opening php tag
add_filter( 'body_class', 'sk_body_class' );
/**
* Add "inner" class to 'body' element for inner pages
* i.e., for all pages other than site's homepage/front page.
*
* @author Sridhar Katakam
* @link http://sridharkatakam.com/add-inner-body-class-inner-pages-wordpress/
@lmartins
lmartins / gist:cdafd234879acf5e2160
Created October 8, 2014 07:45 — forked from corsonr/gist:7370707
WooCommerce - display order coupons used in confirmation email and edit order page
add_action( 'woocommerce_email_after_order_table', 'add_payment_method_to_admin_new_order', 15, 2 );
/**
* Add used coupons to the order confirmation email
*
*/
function add_payment_method_to_admin_new_order( $order, $is_admin_email ) {
if ( $is_admin_email ) {
@lmartins
lmartins / gist:04f81dbad4246fd49d1e
Created October 8, 2014 07:43 — forked from corsonr/gist:9071214
WooCommerce - Store terms and conditions value within the database
<?php
/**
* Store terms and conditions value within the database
**/
add_action('woocommerce_checkout_update_order_meta', 'woo_save_terms_and_conditions_status');
function woo_save_terms_and_conditions_status( $order_id ) {
if ($_POST['terms']) update_post_meta( $order_id, '_terms', esc_attr($_POST['terms']));
}
@lmartins
lmartins / gist:cc13a804a7bcea1bd1b0
Created October 8, 2014 07:41 — forked from corsonr/gist:e5e5c5fc944c278049de
WooCommerce Subscriptions: edit sign-up button text
<?php
function woocommerce_custom_subscription_product_single_add_to_cart_text( $text = '' , $post = '' ) {
global $product;
if ( $product->is_type( 'subscription' ) ) {
$text = get_option( WC_Subscriptions_Admin::$option_prefix . '_add_to_cart_button_text', __( 'Sign Up Now', 'woocommerce-subscriptions' ) );
} else {
$text = $product->add_to_cart_text(); // translated "Read More"
}