Skip to content

Instantly share code, notes, and snippets.

@shreyans94
shreyans94 / gist:065bfdf21ebff9556356d0d944a80318
Created August 1, 2017 08:03
Sort out of stock in category & Shop pages for Woocommerce
// Add custom Theme Functions here
/**
* Sorting out of stock WooCommerce products - Order product collections by stock status, in-stock products first.
*/
class iWC_Orderby_Stock_Status
{
public function __construct()
{
// Check if WooCommerce is active
@shreyans94
shreyans94 / gist:f8d11af839dfc2e11b1d6a281077028a
Created January 23, 2018 21:32
Change woocommerce price format from range to "From:"
/**
* Change price format from range to "From:"
*
* @param float $price
* @param obj $product
* @return str
*/
function iconic_variable_price_format( $price, $product ) {
$prefix = sprintf('%s: ', __('From', 'iconic'));
@shreyans94
shreyans94 / gist:c2b99d03b2c57696fb4627f2b0a8c3ca
Created January 23, 2018 21:34
Coupon Restriction option in WooCommerce Smart COD Plugin
add_filter( 'wc_smart_cod_available', 'cod_restrict_coupons' );
function cod_restrict_coupons( $is_cod_available ) {
global $woocommerce;
$applied_coupons = $woocommerce->cart->applied_coupons;
// add the coupon codes you want
// to restrict in this array
$restricted_coupons = array(
/* Yith Add 'Submit review' Link on Top */
if( defined('YITH_YWAR_PREMIUM') ){
add_action( 'ywar_summary_prepend','yith_ywar_show_submit_review_link',5 );
function yith_ywar_show_submit_review_link(){
echo '<a href="#review_form_wrapper">Submit review</a>';
}
}
@shreyans94
shreyans94 / gist:1855adf0b7983e24cf25be5cb4e76886
Created January 23, 2018 21:35
Apply woocommerce product title to all product images alt tags (WooThumbs Compatible)
function iconic_modify_woothumbs_all_images_data( $image_data, $product_id ) {
$title = get_the_title( $product_id );
foreach( $image_data as $index => $image ) {
$image_data[ $index ]['alt'] = $title;
}
return $image_data;
}
@shreyans94
shreyans94 / gist:2c5c927573f6f16a41298e684ff6013d
Created January 23, 2018 21:36
Allow editing of woocommerce orders under status of Processing
add_filter( 'wc_order_is_editable', 'wc_make_processing_orders_editable', 10, 2 );
function wc_make_processing_orders_editable( $is_editable, $order ) {
if ( $order->get_status() == 'processing' ) {
$is_editable = true;
}
return $is_editable;
}
@shreyans94
shreyans94 / gist:0a2a2f96968dc65ba43aa9647c4e7d5f
Created January 23, 2018 21:37
Add scroll feature in Guaven Woo Search Box Plugin
function custom_guaven_js(){
?>
<script>
jQuery(window).scroll(function(){
var guaven_woos_offset = jQuery('.header-search-form-wrapper [name="s"]').offset();
jQuery(".guaven_woos_suggestion").css('left', guaven_woos_offset.left);
jQuery(".guaven_woos_suggestion").css('top', guaven_woos_offset.top + parseFloat(jQuery('.header-search-form-wrapper [name="s"]').outerHeight()));
});
</script>
<?php
@shreyans94
shreyans94 / gist:a36f46b06af060cb95ce12e4d3d8d715
Created January 23, 2018 21:38
Change subject in woocommerce new order email
/**
* @snippet Add Billing First_name to Email Receipt
* @how-to Watch tutorial @ https://businessbloomer.com/?p=19055
* @sourcecode https://businessbloomer.com/?p=19870
* @author Rodolfo Melogli
* @testedwith WooCommerce 2.5.2
*/
add_filter('woocommerce_email_subject_customer_processing_order', 'bbloomer_change_processing_email_subject', 10, 2);
@shreyans94
shreyans94 / gist:7e8da767176feb1dda5966c8f0dcb79f
Created January 23, 2018 21:38
WooCommerce Variations Ajax Fix
function iconic_wc_ajax_variation_threshold( $qty, $product ) {
return 50;
}
add_filter( 'woocommerce_ajax_variation_threshold', 'iconic_wc_ajax_variation_threshold', 10, 2 );
@shreyans94
shreyans94 / gist:7fbd541c7298908304fbea4a14de92fd
Created January 23, 2018 21:39
Add Sale Badge On Product Page (WooThumbs Comaptibility)
add_action('woocommerce_before_single_product_summary','flatsome_sale_flash_custom',21);
function flatsome_sale_flash_custom(){
do_action('flatsome_sale_flash');
}