Skip to content

Instantly share code, notes, and snippets.

View rynaldos-zz's full-sized avatar

Rynaldo rynaldos-zz

View GitHub Profile
function woo_ninja_remove_price_range( $price, $product ) {
// Main Price
$prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
$price = $prices[0] !== $prices[1] ? sprintf( __( '%1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
// Sale Price
$prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) );
sort( $prices );
$saleprice = $prices[0] !== $prices[1] ? sprintf( __( '%1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
@rynaldos-zz
rynaldos-zz / localize-datepicker.php
Created February 18, 2016 11:24
Localizing jQuery UI Datepicker
add_filter( 'wp_footer' , 'rc_localize_datepicker' );
/**
* Localize datepicker fields
*
* @access public
* @since 1.0
* @return void
*/
function rc_localize_datepicker() {
@rynaldos-zz
rynaldos-zz / cnorp.php
Created May 9, 2016 18:25
Change number of related products
function woo_related_products_limit() {
global $product;
$args['posts_per_page'] = 6;
return $args;
}
add_filter( 'woocommerce_output_related_products_args', 'jk_related_products_args' );
function jk_related_products_args( $args ) {
$args['posts_per_page'] = 6; // 4 related products
$args['columns'] = 3; // arranged in 2 columns
@rynaldos-zz
rynaldos-zz / pricerunner_code.php
Created May 17, 2016 10:46
Thankyou Page (Pricerunner code)
add_action( 'woocommerce_thankyou', 'my_custom_code' );
function my_custom_code() {
?>
<!-- My Custom Code -->
<script src ="https://research.pricerunner.com/cgi-bin/quest/cssi.js?quest=102&client=CID"></script><a href="#" onclick="launchCSS()">Skriv in den text ni vill visa för länken här</a>
<?php
}
@rynaldos-zz
rynaldos-zz / no-sidebar-shop.php
Created May 19, 2016 11:21
Remove sidebar from shop page (Storefront)
/* Remove Sidebar from Shop Page */
add_action( 'get_header', 'remove_storefront_sidebar' );
function remove_storefront_sidebar() {
if ( is_shop() ) {
remove_action( 'storefront_sidebar', 'storefront_get_sidebar', 10 );
}
}
@rynaldos-zz
rynaldos-zz / disable_pass-strength.php
Created July 21, 2016 19:01
Password Strength Disable
function wc_ninja_remove_password_strength() {
if ( wp_script_is( 'wc-password-strength-meter', 'enqueued' ) ) {
wp_dequeue_script( 'wc-password-strength-meter' );
}
}
add_action( 'wp_print_scripts', 'wc_ninja_remove_password_strength', 100 );
@rynaldos-zz
rynaldos-zz / hide-trs-string.php
Created July 22, 2016 10:24
Hide TRS String in Cart / Checkout
.cart_totals tr.shipping td,
#order_review tr.shipping td {
visibility: hidden;
float: left;
}
.cart_totals tr.shipping td span.amount,
#order_review tr.shipping td span.amount {
visibility: visible;
float: left;
@rynaldos-zz
rynaldos-zz / wc-vsl.php
Created September 21, 2016 09:40
Filter to add variable stock level totals back to admin
add_filter( 'woocommerce_admin_stock_html', 'tmt_show_variation_stock_level', 10, 2 );
function tmt_show_variation_stock_level( $stock_html, $the_product ) {
if( sizeof( $the_product->get_children() ) ) {
$stock_html .= ' (' . $the_product->get_total_stock() . ')';
}
@rynaldos-zz
rynaldos-zz / wc-redirect-cus-role-home.php
Created February 3, 2017 07:34
[WooCommerce] Redirect users from my-account page (based on role)
add_filter('woocommerce_login_redirect', 'wc_login_redirect', 10, 2 );
function wc_login_redirect( $redirect_to, $user ) {
$role = $user->roles[0];
$myaccount = get_permalink( wc_get_page_id( 'myaccount' ) );
if( $role == 'customer' ) {
$redirect_to = home_url();
}
return $redirect_to;
}
@rynaldos-zz
rynaldos-zz / continue-shopping-redirect-link.php
Last active February 3, 2017 07:37
[WooCommerce] Replace the Continue shopping button link (shop page)