Skip to content

Instantly share code, notes, and snippets.

View themepaint's full-sized avatar

Shariful Islam themepaint

View GitHub Profile
@themepaint
themepaint / Woocommerce Product Compare with YIT
Created February 3, 2016 08:14
Woocommerce Product Compare withYIT
<div class="woocommerce product compare-button">
<?php
echo '<a href="' . get_permalink( $product->id ) . '&amp;action=yith-woocompare-add-product&amp;id=' . $product->id . '" class="compare button" data-product_id="' . $product->id . '"><i class="fa fa-refresh"></i></a>';
?>
</div>
@themepaint
themepaint / compare button Text Remove & Style
Last active February 7, 2016 07:16
compare button Text Remove & Style
// compare button
if( class_exists( 'YITH_Woocompare_Frontend' ) ) {
class ComBtn extends YITH_Woocompare_Frontend{
public function enqueue_scripts() {
// scripts
wp_enqueue_script( 'yith-woocompare-main', YITH_WOOCOMPARE_ASSETS_URL . '/js/woocompare.js', array('jquery'), $this->version, true );
wp_localize_script( 'yith-woocompare-main', 'yith_woocompare', array(
@themepaint
themepaint / Remove Additional Notes from WooCommerce Checkout
Last active February 9, 2016 08:01
Remove Additional Notes from WooCommerce Checkout
// Use It In functions.php
add_filter( 'woocommerce_enable_order_notes_field', '__return_false' );
@themepaint
themepaint / Display “ Out of Stock ” on catalog view Woocommerce
Created February 9, 2016 08:14
Display “ Out of Stock ” on catalog view Woocommerce
function wcs_stock_text_shop_page() {
//returns an array with 2 items availability and class for CSS
global $product;
$availability = $product->get_availability();
//check if availability in the array = string 'Out of Stock'
//if so display on page.//if you want to display the 'in stock' messages as well just leave out this, == 'Out of stock'
if ( $availability['availability'] == 'Out of stock') {
echo apply_filters( 'woocommerce_stock_html', '<span class="' . esc_attr( $availability['class'] ) . '">' . esc_html( $availability['availability'] ) . '</p>', $availability['availability'] );
}
@themepaint
themepaint / WooCommerce – Check if product is already in cart
Created February 21, 2016 18:28
WooCommerce – Check if product is already in cart
<?php
/**
* Change the add to cart text on single product pages
*/
add_filter('woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text');
function woo_custom_cart_button_text() {
foreach( WC()->cart->get_cart() as $cart_item_key => $values ) {
$_product = $values['data'];
@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] );
@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 / 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 / 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 / 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">';