This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Ensure cart contents update when products are added to the cart via AJAX (place the following in functions.php) | |
add_filter( 'woocommerce_add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment' ); | |
function woocommerce_header_add_to_cart_fragment( $fragments ) { | |
ob_start(); | |
?> | |
<a class="cart-contents" href="<?php echo wc_get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf (_n( '%d item', '%d items', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?> - <?php echo WC()->cart->get_cart_total(); ?></a> | |
<?php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function translate_text( $translated ) { | |
// The first parameter is the original text, the second parameter is the changed text. | |
$translated = str_ireplace( 'Choose and option', 'Select', $translated ); | |
// Returns the translated text | |
return $translated; | |
} | |
add_filter( 'gettext', 'translate_text' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The following goes in functions.php | |
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_stock', 10); | |
function woocommerce_template_loop_stock() { | |
global $product; | |
if ( ! $product->managing_stock() && ! $product->is_in_stock() ) | |
echo '<p class="stock out-of-stock">out-of-stock</p>'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// hide coupon field on cart page | |
function hide_coupon_field_on_cart( $enabled ) { | |
if ( is_cart() ) { | |
$enabled = false; | |
} | |
return $enabled; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add the code below to your theme's functions.php file to add a confirm password field on the register form under My Accounts. | |
add_filter('woocommerce_registration_errors', 'registration_errors_validation', 10,3); | |
function registration_errors_validation($reg_errors, $sanitized_user_login, $user_email) { | |
global $woocommerce; | |
extract( $_POST ); | |
if ( strcmp( $password, $password2 ) !== 0 ) { | |
return new WP_Error( 'registration-error', __( 'Passwords do not match.', 'woocommerce' ) ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_add_to_cart', 'check_total_weight' ); | |
function check_total_weight( $itemkey, $product_id, $quantity ){ | |
$product = wc_get_product( $product_id ); | |
$weight = $product->get_weight() * $quantity; | |
$cart_weight = WC()->cart->cart_contents_weight; | |
if( $weight + $cart_weight > {TOTAL} ){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Mixins: | |
*/ | |
//make flex rows a bit easier: | |
@mixin flex-row( $equalize:stretch ){ | |
@include display(flex); | |
@include flex-direction(row); | |
@include align-items($equalize); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
##Device = Desktops | |
##Screen = 1281px to higher resolution desktops | |
*/ | |
@media (min-width: 1281px) { | |
/* CSS */ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add order again button in my orders actions. | |
* | |
* @param array $actions | |
* @param WC_Order $order | |
* @return array | |
*/ | |
function cs_add_order_again_to_my_orders_actions( $actions, $order ) { | |
if ( $order->has_status( 'completed' ) ) { |