Skip to content

Instantly share code, notes, and snippets.

@jitenbharadava
Created December 30, 2015 13:31
Show Gist options
  • Select an option

  • Save jitenbharadava/0804e5ce99b0b77bf752 to your computer and use it in GitHub Desktop.

Select an option

Save jitenbharadava/0804e5ce99b0b77bf752 to your computer and use it in GitHub Desktop.
Woocommrece Snppit
// Product Page Image Seting //
<?php
error_reporting(0);
function woocommerce_template_loop_product_thumbnail(){
global $product;
$link = get_permalink( $product->id );
$imgsrc_full = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "full");
$imgsrc_thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "thumbnail");
?>
<a href="<?php echo $link; ?>"><img src="<?php echo $imgsrc_thumbnail[0]; ?>"/></a>
<a class="fancybox" href="<?php echo $imgsrc_full[0]; ?>"><img src="<?php echo $imgsrc_thumbnail[0]; ?>"/></a> //lightbox code
<?php
}
// Shop Page Caetgory Lebal Change///
add_filter( 'woocommerce_loop_add_to_cart_link', 'wc_custom_redirect_add_to_cart', 10, 2 );
function wc_custom_redirect_add_to_cart( $html, $product ) {
return sprintf( '<a href="%s" data-product_id="%s" data-product_sku="%s" data-quantity="%s" class="button product_type_%s">%s</a>',
esc_url( get_permalink( $product->id ) ),
esc_attr( $product->id ),
esc_attr( $product->get_sku() ),
esc_attr( isset( $quantity ) ? $quantity : 1 ),
esc_attr( $product->product_type ),
esc_html( 'View Product' )
);
}
// Search Filter //
function xyz_filter_search($query)
{
if ($query->is_search)
{
$query->set('post_type', array(
'post',
'product'
));
}
return $query;
}
// Lebal Change Product//
add_filter('add_to_cart_text', 'woo_custom_cart_button_text');
function woo_custom_cart_button_text() {
return __('View Product', 'woocommerce');
}
//remove the product description tab
add_filter( 'woocommerce_product_tabs', 'woo_custom_remove_product_tabs', 98 );
function woo_custom_remove_product_tabs( $tabs ) {
unset( $tabs['description'] ); // Remove the description tab
return $tabs;
}
//Price name change
add_filter('woocommerce_get_price_html', 'woo_custom_price_html');
function woo_custom_price_html($price) {
if(empty($price))
$price = 'Call for Pricing';
return $price;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment