Skip to content

Instantly share code, notes, and snippets.

<p style="text-align: center;">text</p>
@nickburne
nickburne / gist:192609fedc540654fd9b
Last active September 16, 2015 23:25
Replace add to cart button with button to product page - WooCommerce
/*PUT THIS IN YOUR CHILD THEME FUNCTIONS FILE*/
/*STEP 1 - REMOVE ADD TO CART BUTTON ON PRODUCT ARCHIVE (SHOP) */
function remove_loop_button(){
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
}
add_action('init','remove_loop_button');
@nickburne
nickburne / Delete the sidebar in WooCommerce
Created April 30, 2014 14:56
Delete the sidebar in WooCommerce
<?php get_header(); ?>
<div id="container">
<div id="content-wrap">
<?php woocommerce_content(); ?>
</div>
</div>
<?php get_footer(); ?>
@nickburne
nickburne / Add a background image to the shop page only in WooCommerce
Created April 30, 2014 14:51
Add a background image to the shop page only in WooCommerce
add_filter( 'wp_head', 'wo_custom_shop_background' );
function wo_custom_shop_background() {
if( is_shop() && !is_admin() ) {
?>
<style>
body {
background: url(http://blogs.smithsonianmag.com/smartnews/files/2013/08/06177001.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
@nickburne
nickburne / Customise ‘add to cart’ text on single product pages in WooCommerce
Created April 30, 2014 14:35
Customise ‘add to cart’ text on single product pages in WooCommerce
add_filter( 'add_to_cart_text', 'woo_custom_cart_button_text' ); // < 2.1
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text' ); // 2.1 +
function woo_custom_cart_button_text() {
return __( 'My Button Text', 'woocommerce' );
}
@nickburne
nickburne / Add a checkbox field to checkout with a simple snippet in WooCommerce
Created April 30, 2014 14:32
Add a checkbox field to checkout with a simple snippet in WooCommerce
<?php
/**
* Add checkbox field to the checkout
**/
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
function my_custom_checkout_field( $checkout ) {
echo '<div id="my-new-field"><h3>'.__('My Checkbox: ').'</h3>';
woocommerce_form_field( 'my_checkbox', array(
'type' => 'checkbox',
'class' => array('input-checkbox'),
@nickburne
nickburne / Automatically mark orders as ‘complete’ in WooCommerce
Created April 30, 2014 14:29
Automatically mark orders as ‘complete’ in WooCommerce
add_filter( 'woocommerce_payment_complete_order_status', 'virtual_order_payment_complete_order_status', 10, 2 );
function virtual_order_payment_complete_order_status( $order_status, $order_id ) {
$order = new WC_Order( $order_id );
if ( 'processing' == $order_status &&
( 'on-hold' == $order->status || 'pending' == $order->status || 'failed' == $order->status ) ) {
$virtual_order = null;
if ( count( $order->get_items() ) > 0 ) {
foreach( $order->get_items() as $item ) {
if ( 'line_item' == $item['type'] ) {
$_product = $order->get_product_from_item( $item );
@nickburne
nickburne / Alter the default state and country at the checkout
Created April 30, 2014 14:27
Alter the default state and country at the checkout
/**
* 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() {
return 'XX'; // country code
}
@nickburne
nickburne / Automatically complete orders in WooCommerce
Created April 30, 2014 14:23
Automatically complete orders in WooCommerce
/**
* Auto Complete all WooCommerce orders.
* Add to theme functions.php file
*/
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
function custom_woocommerce_auto_complete_order( $order_id ) {
global $woocommerce;
if ( !$order_id )
@nickburne
nickburne / Remove duplicate stars on your product
Created April 29, 2014 10:56
Remove duplicate stars on your product
.star-rating span:before, ul.products li.product .product-details .star-rating:before {
content:none;
}