Skip to content

Instantly share code, notes, and snippets.

View spraveenitpro's full-sized avatar

Praveen spraveenitpro

View GitHub Profile
@spraveenitpro
spraveenitpro / roll16.py
Last active August 4, 2021 16:56
Write a program in Python where you generate a random integer from 1 to 16 inclusive where your only random number generator is a six-sided die. Assume a function named roll6 which returns a 1, 2, 3, 4, 5 or 6 and write a function named roll16 which returns an integer between 1 and 16 inclusive.
import random
# Roll6 function to return random number between 1 and 6
def roll6():
return(random.randint(1,6))
# Roll16 function to call Roll6 function thrice
# Our range with 3 dices are 3 - 18, so I am deducting 2 to set the range from 1 to 16
def roll16():
value = (roll6() + roll6() + roll6()) - 2
@spraveenitpro
spraveenitpro / gist:20a918c4e28448e6132b6ca19302c776
Created July 3, 2017 06:45
Add Suffix to product prices in WooCommerce Cart
add_filter( 'woocommerce_cart_item_price', 'kd_custom_price_message' );
add_filter( 'woocommerce_cart_item_subtotal', 'kd_custom_price_message' );
add_filter( 'woocommerce_cart_subtotal', 'kd_custom_price_message' );
add_filter( 'woocommerce_cart_total', 'kd_custom_price_message' );
function kd_custom_price_message( $price ) {
$afterPriceSymbol = ' Inc. GST';
return $price . $afterPriceSymbol;
}
@spraveenitpro
spraveenitpro / gist:45447cd48066ee13f41293e8351c76c4
Last active June 20, 2017 08:38 — forked from ChromeOrange/gist:6533754
Example template.php file for re-ordering the Order details
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style>
@page {
margin: 480px 50px 150px 50px;
}
#header {
position: fixed;
left: 0px;
@spraveenitpro
spraveenitpro / gist:d4718c15e5f20f988526
Last active December 11, 2015 06:37
Minimum, Maximum and a Step for product dropdown
function woocommerce_quantity_input() {
global $product;
$defaults = array(
'input_name' => 'quantity',
'input_value' => '1',
'max_value' => apply_filters( 'woocommerce_quantity_input_max', '20000', $product ),
'min_value' => apply_filters( 'woocommerce_quantity_input_min', '1000', $product ),
'step' => apply_filters( 'woocommerce_quantity_input_step', '1000', $product ),
'style' => apply_filters( 'woocommerce_quantity_style', 'float:left; margin-right:10px;', $product )
);
@spraveenitpro
spraveenitpro / gist:8f82dffe41e44fc640e3
Created December 9, 2015 05:22
Declare WooCommerce Support
add_action( 'after_setup_theme', 'woocommerce_support' );
function woocommerce_support() {
add_theme_support( 'woocommerce' );
}
@spraveenitpro
spraveenitpro / gist:6e186eb63dafb6475569
Created June 26, 2015 04:10
Change the number of Products per page to 12
//change the number of Products per page to 12
add_filter( 'loop_shop_per_page', 'change_number_of_products', 20, 1);
function change_number_of_products( $cols ) {
return 12;
}
@spraveenitpro
spraveenitpro / gist:d34c0edd746aa490e516
Created June 22, 2015 07:56
Enable Tax for local Pickup Shipping method
//Enable Tax for local Pickup
add_filter( 'woocommerce_apply_base_tax_for_local_pickup', '__return_false' );
@spraveenitpro
spraveenitpro / gist:adc315db2e1a1af16e00
Last active August 29, 2015 14:23
Change the number of Wishlists being displayed when using the [wc_wishlists_search] shortcode
// Change the number of Wishlists being displayed
add_filter( 'woocommerce_wishlist_posts_per_page', 'change_wishlist_number', 10, 1 );
function change_wishlist_number( $number ){
return 14; //use required number here
}
@spraveenitpro
spraveenitpro / gist:52007067f98b35a9a203
Created June 19, 2015 04:10
Custom message upon entering a valid coupon
// define the woocommerce_coupon_message callback
function filter_woocommerce_coupon_message( $msg, $msg_code, $instance )
{
$msg = "Yeah thanks!";
return $msg;
};
// add the filter
add_filter( 'woocommerce_coupon_message', 'filter_woocommerce_coupon_message', 10, 3 );
@spraveenitpro
spraveenitpro / gist:1db005951274ef51779d
Last active August 29, 2015 14:23
Setup Step, min and max for Simple and Variable products
// Simple products
add_filter( 'woocommerce_quantity_input_args', 'jk_woocommerce_quantity_input_args', 10, 2 );
function jk_woocommerce_quantity_input_args( $args, $product ) {
$args['input_value'] = 3; // Starting value
$args['max_value'] = 12; // Maximum value
$args['min_value'] = 3; // Minimum value
$args['step'] = 3; // Quantity steps
return $args;
}