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
# Swappable Mixins in CoffeeScript
# ================================
# Many thanks to Hashmal, who wrote this to start.
# https://gist.github.com/803816/aceed8fc57188c3a19ce2eccdb25acb64f2be94e
# Usage
# -----
# class Derp extends Mixin
@lmartins
lmartins / gist:8a0643b32efd4592125e
Created October 8, 2014 07:40 — forked from corsonr/gist:ba033db9978a536b2b05
Show products weight in the cart process
<?php
// Store cart weight in the database
add_action('woocommerce_checkout_update_order_meta', 'woo_add_cart_weight');
function woo_add_cart_weight( $order_id ) {
global $woocommerce;
$weight = $woocommerce->cart->cart_contents_weight;
update_post_meta( $order_id, '_cart_weight', $weight );
}
@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"
}
@lmartins
lmartins / gist:c84fc899832cf7b560b7
Last active August 29, 2015 14:07 — forked from corsonr/gist:3ac30cc334cf344dbb3b
Change related products thumbnail size
<?php
add_filter( 'wp_head' , 'related_products_style' );
function related_products_style() {
if( is_product() ) :
?>
<style>
.woocommerce .related ul.products li.product, .woocommerce .related ul li.product, .woocommerce .upsells.products ul.products li.product, .woocommerce .upsells.products ul li.product, .woocommerce-page .related ul.products li.product, .woocommerce-page .related ul li.product, .woocommerce-page .upsells.products ul.products li.product, .woocommerce-page .upsells.products ul li.product {
width: 24% !important;
@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: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
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 / 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
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() )