Skip to content

Instantly share code, notes, and snippets.

@aderaaij
aderaaij / functions.php
Last active November 12, 2017 15:35
Default functions.php
<?php
require_once('includes/-.php');
require_once('includes/-.php');
require_once('includes/-.php');
require_once('includes/-.php');
@aderaaij
aderaaij / wc-remove-add-to-cart.php
Created July 24, 2014 12:57
Remove add to cart on archive loop
<?php
add_action( 'woocommerce_after_shop_loop_item', 'remove_add_to_cart_buttons', 1 );
function remove_add_to_cart_buttons() {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
}
@aderaaij
aderaaij / wc-remove-quantity.php
Created July 24, 2014 10:06
Remove quantity selector
<?php
/**
* @desc Remove in all product type
*/
function wc_remove_all_quantity_fields( $return, $product ) {
return true;
}
add_filter( 'woocommerce_is_sold_individually', 'wc_remove_all_quantity_fields', 10, 2 );
@aderaaij
aderaaij / wc-remove-sku.php
Created July 24, 2014 09:53
Remove SKU from product page
<?php
/**
* Remove "SKU" from product details page.
*/
add_filter( 'wc_product_sku_enabled', 'mycode_remove_sku_from_product_page' );
function mycode_remove_sku_from_product_page( $boolean ) {
if ( is_single() ) {
$boolean = false;
}
@aderaaij
aderaaij / wc-remove-result-count.php
Created July 24, 2014 08:55
Remove result count (in archive or after ordering)
<?php
// remove woocommerce result count
function woocommerce_result_count() {
return;
}
@aderaaij
aderaaij / wc-remove-breadcrumbs.php
Created July 24, 2014 08:28
Remove Woocommerce breadcrumbs
<?php
//remove Breadcrumbs
remove_action( 'woocommerce_before_main_content','woocommerce_breadcrumb', 20, 0);
<?php
remove_action('woocommerce_sidebar', 'woocommerce_get_sidebar', 10);
@aderaaij
aderaaij / wc-reorder-fields.php
Last active November 12, 2017 15:34
Customizing Checkout Field Order http://wordimpress.com/15-woocommerce-code-snippets-im-thankful-for/ Sometimes the default ordering of fields isn’t optimal for your business. You can modify the order the fields appear by customizing the following function:
<?php
add_filter( 'woocommerce_checkout_fields', 'reorder_woo_fields' );
function reorder_woo_fields( $fields ) {
//move these around in the order you'd like
$fields2['billing']['billing_first_name'] = $fields['billing']['billing_first_name'];
$fields2['billing']['billing_last_name'] = $fields['billing']['billing_last_name'];
$fields2['billing']['billing_company'] = $fields['billing']['billing_company'];
$fields2['billing']['billing_address_1'] = $fields['billing']['billing_address_1'];
$fields2['billing']['billing_address_2'] = $fields['billing']['billing_address_2'];
@aderaaij
aderaaij / wc-custom-continue-redirect.php
Created July 17, 2014 13:25
Changes link destination of 'Continue Shopping' button on cart page http://webandtechstuff.com/continue-shopping-button-woocommerce-cart/
<?php
// Changes link destination of 'Continue Shopping' button on cart page
add_filter( 'woocommerce_continue_shopping_redirect', 'my_custom_continue_redirect' );
function my_custom_continue_redirect( $url ) {
return 'http://mydomain.com/url';
}
@aderaaij
aderaaij / wc-npr-filter-phone.php
Created July 17, 2014 10:36
Phonenumber not required
<?php
//phone number not required
add_filter( 'woocommerce_billing_fields', 'wc_npr_filter_phone', 10, 1 );
function wc_npr_filter_phone( $address_fields ) {
$address_fields['billing_phone']['required'] = false;
return $address_fields;
}