Skip to content

Instantly share code, notes, and snippets.

View themepaint's full-sized avatar

Shariful Islam themepaint

View GitHub Profile
@themepaint
themepaint / Register Custom Taxonomy Woocommerce Products
Created April 22, 2016 11:59
Register Custom Taxonomy Woocommerce Products
// Register Custom Taxonomy
function ess_custom_taxonomy_Item() {
$labels = array(
'name' => 'Brands',
'singular_name' => 'Brand',
'menu_name' => 'Brands',
'all_items' => 'All Brands',
'parent_item' => 'Parent Brand',
'parent_item_colon' => 'Parent Brand:',
@themepaint
themepaint / remove add to cart button from a certain category Woocommerce
Last active April 9, 2022 22:22
remove add to cart button from a certain category Woocommerce
function themepaint_custom_cart_buttons(){
$product = get_product();
if ( has_term( 'posters', 'product_cat') ){
// removing the purchase buttons
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
@themepaint
themepaint / Woocommerce Price Filter CSS
Created February 2, 2016 08:20
Woocommerce Price Filter CSS
.price_slider{
margin-bottom: 1em;
}
.price_slider_amount {
text-align: right;
line-height: 2.4em;
font-size: 0.8751em;
}
@themepaint
themepaint / Woocommerce cart text change
Created January 28, 2018 04:16
Woocommerce cart change by putting the code in functions.php
//archive page or main page
add_filter( 'woocommerce_product_add_to_cart_text', 'woo_custom_product_add_to_cart_text_themepaint' ); // 2.1 +
function woo_custom_product_add_to_cart_text_themepaint() {
return __( 'Buy it on ebay', 'woocommerce' );
}
@themepaint
themepaint / Create Custome Field in Woocommerce Product Page
Created April 18, 2016 09:05
Create Custome Field in Woocommerce Product Page
<?php
// Display Fields
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );
function woo_add_custom_general_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
<?php
/*Product DIscount Calculation*/
//put it on Function
function discount_product(){
global $product;
$discount = $product->sale_price ;
if ($discount) {
$percentage = round( ( ( $product->regular_price - $product->sale_price ) / $product->regular_price ) * 100 );
$wc_percent = $price .' <span class="product-discount">'. sprintf( __('%s', 'cruise' ), $percentage . '% OFF</span>' );
}
@themepaint
themepaint / Woocommerce product type detection and cart text change
Created October 7, 2016 20:27
Woocommerce product type detection and cart text change
add_filter( 'woocommerce_product_single_add_to_cart_text', 'custom_single_add_to_cart_text' );
function custom_single_add_to_cart_text() {
global $product;
if( $product->is_type( 'variable' ) ){
return __( 'HD Download', 'woocommerce' );
}else{
@themepaint
themepaint / Change Default shipping methode.
Last active March 30, 2016 16:57
Change Default shipping methode.
/**
* woocommerce_package_rates is a 2.1+ hook
*/
add_filter( 'woocommerce_package_rates', 'hide_shipping_when_free_is_available', 10, 2 );
/**
* Hide shipping rates when free shipping is available
*
* @param array $rates Array of rates found for the package
* @param array $package The package array/object being shipped
@themepaint
themepaint / Remove WooCommerce purchase button on a category
Created March 28, 2016 09:07
Remove WooCommerce purchase button on a category
function themepaint_custome_add_to_cart(){
if ( ! is_product() ) return;
$product = get_product();
if ( has_term('posters','product_cat',$product ) || themepaint_is_child_of_turm( 'posters','product_cat',$product )) {
/**
* Product Add to cart.
*
* @see woocommerce_template_single_add_to_cart()
@themepaint
themepaint / price variation show lowest price in woocommerce
Created March 25, 2016 22:11
price variation show lowest price in woocommerce
function wc_ninja_custom_variable_price( $price, $product ) {
// Main Price
$prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
$price = $prices[0] !== $prices[1] ? sprintf( __( 'From: %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( __( 'From: %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );