Skip to content

Instantly share code, notes, and snippets.

View rameshelamathi's full-sized avatar

Ramesh Elamathi rameshelamathi

View GitHub Profile
@rameshelamathi
rameshelamathi / snippet.php
Created August 21, 2019 13:58
Retainful Add to Cart popup additional classes support
add_filter('retainful_premium_add_to_cart_collection_button_classes',function($classes){
return array('add_to_cart_button_classes' => '.elementor-button-link');
});
These lines around line number 5472
if ("" !== n && "" === $j(this).attr("href").split("#")[0] || "" !== n && "" !== $j(this).attr("href").split("#")[0] && n === window.location.hash || "" !== n && $j(this).attr("href").split("#")[0] === window.location.href.split("#")[0]) {
should be changed to something like:
var $href = $j(this).attr("href") ? $j(this).attr("href").split("#")[0] : "";
if ("" !== n && "" === $href || "" !== n && "" !== $href && n === window.location.hash || "" !== n && $href === window.location.href.split("#")[0]) {
@rameshelamathi
rameshelamathi / retainful-default-email-template.html
Created May 23, 2019 08:35
Retainful Default Email Template
<body style="background: rgb(255, 255, 255);">
<div class="mj-container" style="background-color:#fff;">
<!--[if mso | IE]>
<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="520" align="center" style="width:600px;">
<tr>
<td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">
<![endif]-->
<div style="margin:0px auto;max-width:600px;background:#00D2C2;">
<table role="presentation" cellpadding="0" cellspacing="0" style="font-size:0px;width:100%;background:#00D2C2;" align="center" border="0">
<tbody>
<?php
/**
* @package J2Store
* @copyright Copyright (c)2014-17 Ramesh Elamathi / J2Store.org
* @license GNU GPL v3 or later
*/
// No direct access to this file
defined('_JEXEC') or die;
/**
@rameshelamathi
rameshelamathi / snippet.php
Created February 7, 2019 15:51
Snippet to resolve update cart on quantity change in Avada theme in WooCommerce
function add_woo_discount_rules_custom_script(){
?>
<script>
function click_update_cart_btn(upd_cart_btn) {
var upd_cart_btn = jQuery(".fusion-update-cart");
upd_cart_btn.trigger("click");
}
@rameshelamathi
rameshelamathi / coupons.php
Last active January 4, 2019 14:04
Automatically apply coupon in WooCommerce based on Cart Subtotal
//How to provide a tiered, cart subtotal based discount automatically in WooCommerce.
//The snippet assumes that you wanted to provide a fixed discount amount
function auto_apply_coupons_based_on_cart_subtotal() {
//NOTE: You must create the coupon codes first for these 5 tiers and replace the coupon code in the respective lines below
//$10 discount for purchases above $100
$get1 = 'MYCOUPON10'; //your coupon code for $10 discount
@rameshelamathi
rameshelamathi / tags
Last active October 4, 2019 12:31
Tags as categories for Woo Discount Rules
function woo_discount_rules_accepted_taxonomy_for_category_method($taxonomy){
$taxonomy[] = 'product_tag';
return $taxonomy;
}
add_filter('woo_discount_rules_accepted_taxonomy_for_category', 'woo_discount_rules_accepted_taxonomy_for_category_method', 10);
function woo_discount_rules_load_additional_taxonomy_method($categories, $product_id){
$taxonomy_to_apply = 'product_tag';
$tags = get_the_terms( $product_id, $taxonomy_to_apply );
@rameshelamathi
rameshelamathi / snippet.php
Created November 29, 2018 15:51
Sale badge custom text
add_filter('woocommerce_sale_flash', 'woocommerce_custom_sale_text', 10, 3);
function woocommerce_custom_sale_text($text, $post, $_product)
{
return '<span class="onsale"> -10% </span>';
}
@rameshelamathi
rameshelamathi / snippet.php
Last active February 26, 2019 16:05
Delete the [Remove] Link
if(!function_exists('fc_woo_applied_coupons_in_cart_html')) {
function fc_woo_applied_coupons_in_cart_html($coupon_html, $coupon, $discount_amount_html) {
$discount_name = 'discount';
//apply only for virtual coupons of woo discount rules
if(isset($coupon->code) && strtoupper($coupon->code) == strtoupper($discount_name)) {
$coupon_html = $discount_amount_html;
}
return $coupon_html;
}
}
@rameshelamathi
rameshelamathi / snippets.php
Last active February 9, 2019 11:24
Change coupon label in WooCommerce
//The following snippet will be useful when you want to display the rule name instead of the standard Coupon: Discount
//while using the Woo Discount Rules plugin
if(!function_exists('woo_applied_cart_rules')) {
function woo_applied_cart_rules($cart_rules_object){
global $applied_rules;
$applied_rules = array();
if(isset($cart_rules_object->matched_discounts)) {
global $applied_rules;
$applied_rules = $cart_rules_object->matched_discounts;