Skip to content

Instantly share code, notes, and snippets.

@ChromeOrange
ChromeOrange / functions-columns.php
Created June 28, 2012 14:00
Change the product columns in WooCommerce
/*
1 - modify your theme functions file
2 - modify the 'loop-shop.php' file
You need to set the 'Product List' value to suit your layout. You will also need to look at changing the CSS if you change from the default WooCommerce values.
1 : Add this to your theme functions file
*/
add_filter('loop_shop_columns', 'wc_product_columns_frontend');
function wc_product_columns_frontend() {
global $woocommerce;
@ChromeOrange
ChromeOrange / functions.php
Created July 12, 2012 10:24
custom_product_filter
<?php
add_filter( 'request', 'custom_product_filter' );
function custom_product_filter( $vars ) {
global $wpdb, $pagenow, $typenow, $wp_query, $woocommerce;
$product_check = '';
$product_check = $_GET['product_check'];
if ( $typenow == 'shop_order' && isset($product_check) && $product_check > 0 ) :
@ChromeOrange
ChromeOrange / theme-functions.php
Created July 18, 2012 12:40
woocommerce_get_catalog_ordering_args
add_filter( 'woocommerce_get_catalog_ordering_args','custom_query_sort_args' );
function custom_query_sort_args() {
// Sort by and order
$current_order = ( isset( $_SESSION['orderby'] ) ) ? $_SESSION['orderby'] : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
switch ( $current_order ) {
case 'date' :
$orderby = 'date';
$order = 'desc';
@ChromeOrange
ChromeOrange / add-to-cart.php
Created July 18, 2012 19:42
Loop Add to Cart
<?php
/**
* Loop Add to Cart
*/
global $product;
if( $product->get_price() === '' && $product->product_type != 'external' ) return;
?>
@ChromeOrange
ChromeOrange / functions.php
Created July 29, 2012 18:37
Allow certain products to be sold one per order only.
<?php
add_filter( 'woocommerce_is_sold_individually', 'cj_woocommerce_is_sold_individually', 10, 2 );
function cj_woocommerce_is_sold_individually( $value, $product ) {
$isi = get_post_meta( $product->id, '_custom_sell_individually', TRUE );
if ( $isi == 'individual' ) :
$return = true;
endif;
@ChromeOrange
ChromeOrange / functions.php
Created July 29, 2012 20:34
Change number of products per page
<?php
add_action( 'init', 'custom_ppp_filter' );
function custom_ppp_filter() {
add_filter( 'loop_shop_per_page','custom_query_ppp_args' );
}
// Posts Per Page Args
function custom_query_ppp_args() {
// Posts Per Page
@ChromeOrange
ChromeOrange / functions.php
Created July 29, 2012 20:48
Add star ratings to the Product category page and by the product name on the single product page
<?php
add_action( 'woocommerce_after_shop_loop_item','show_rating_stars' );
add_action( 'woocommerce_single_product_summary','show_rating_stars',15 );
function show_rating_stars() {
global $woocommerce,$post, $wpdb;
if ( comments_open() ) :
$count = $wpdb->get_var("
@ChromeOrange
ChromeOrange / functions.php
Created July 29, 2012 22:32
Replace all add to cart button text
<?php
// Single Product
add_filter( 'single_add_to_cart_text', 'custom_single_add_to_cart_text' );
function custom_single_add_to_cart_text() {
return 'Add to cart'; // Change this to change the text on the Single Product Add to cart button.
}
// Variable Product
add_filter( 'variable_add_to_cart_text', 'custom_variable_add_to_cart_text' );
@ChromeOrange
ChromeOrange / functions.php
Created July 29, 2012 22:52
Change number of products on homepage #WhiteLight
<?php
// Edit wp-content/themes/whitelight-commerce/functions.php
// Find this on or around line 60
$new_options[] = array( "name" => "Number of Products",
"desc" => "Select the number of products that should appear in the shop area on the home page.",
"id" => $shortname."_shop_area_entries",
"std" => "3",
"class" => "hidden",
"type" => "select",
"options" => $other_entries);
@ChromeOrange
ChromeOrange / functions.php
Created August 4, 2012 12:14
tweak widths of variation drop downs for IE7 and 8
/****
* Paste this into your custom functions file
* 100% should work but you may need to adjust for each browser seperately
*/
function customloadcss() {
$return .= "<!-- Loading CSS -->" . "\r\n";
$return .= "<!--[if IE 7]>" . "\r\n";
$return .= "<style>" . "\r\n";