Skip to content

Instantly share code, notes, and snippets.

View AshlinRejo's full-sized avatar
🏠
Working from home

Ashlin AshlinRejo

🏠
Working from home
View GitHub Profile
@AshlinRejo
AshlinRejo / ordersummary.php
Last active October 28, 2022 11:53
J2Store subscription: Override for show subscription start and end date in order item in back-end
<?php
/**
* @package J2Store
* @copyright Copyright (c)2014-17 Ramesh Elamathi / J2Store.org
* @license GNU GPL v3 or later
*/
/**
* For override copy this file to [BACKEND_TEMPLATE_PATH]/html/com_j2store/myprofile/ordersummary.php
* */
@AshlinRejo
AshlinRejo / orderitems.php
Created October 28, 2022 11:51
J2Store subscription: Override for show subscription start and end date in order item in front-end
<?php
/**
* @package J2Store
* @copyright Copyright (c)2014-17 Ramesh Elamathi / J2Store.org
* @license GNU GPL v3 or later
* This file is for email.
*/
/**
* For override copy this file to [FRONTEND_TEMPLATE_PATH]/html/com_j2store/myprofile/orderitems.php
@AshlinRejo
AshlinRejo / site_main.js
Created October 27, 2022 12:34
Discount rule v2: Customize site js
(function ($) {
/**
* refresh cart when payment method changed
*/
if (awdr_params.refresh_order_review == '1') {
$(document).on('change', 'input[name="payment_method"],input[name="billing_city"],input[name="billing_postcode"]', function () {
refreshCart();
});
/**
@AshlinRejo
AshlinRejo / Discount rule v2: Dynamic strikeout on Shop page.php
Last active October 27, 2022 12:22
Discount rule v2: Dynamic strikeout on Shop page
add_action('wp_footer', function (){
?>
<script>
(function($) {
$(document).ready(function($) {
function wdr_dynamic_pricestrikeout(currentObject){
var awdr_qty_object = currentObject.closest('form').find('input[name="quantity"]');
setTimeout(function() {
var $qty = awdr_qty_object.val();
var $product_id = 0;
@AshlinRejo
AshlinRejo / Discount rules v2: Show only discounted price without strikeout for selected rule
Created October 25, 2022 11:04
Discount rules v2: Show only discounted price without strikeout for selected rule
/**
* Show only discounted price without strikeout for selected rule
* Products which has other rules will have strikeout
* */
if(!function_exists('showOnlyDiscountPriceWithoutStrikeout')){
function showOnlyDiscountPriceWithoutStrikeout($product, $discounts = false){
$awdr_rules_to_exclude_strikeout = array(1); // REPLACE THE RULE IDS HERE FOR WHICH WE NEED TO EXCLUDE STRIKEOUT eg: array(10,12)
$price = $product->get_price();
if($discounts == false){
$discounts = apply_filters('advanced_woo_discount_rules_get_product_discount_price_from_custom_price', $price, $product, 1, $price, 'all', true, false);
@AshlinRejo
AshlinRejo / discount_table.php
Created October 19, 2022 11:18
Discount rules v2: Show only minimum range with + in discount table
<?php
/**
* Discount table
*
* This template can be overridden by copying it to yourtheme/advanced_woo_discount_rules/discount_table.php.
*
* HOWEVER, on occasion Discount rules will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
@AshlinRejo
AshlinRejo / J2Store subscription: Alert box for Subscription cancel button
Created October 19, 2022 09:56
J2Store subscription: Alert box for Subscription cancel button
<?php
defined('_JEXEC') or die('Restricted access');
unset ( $listOrder );
$listOrder = $vars->data->state->get ( 'filter_order', 'tbl.user_id' );
$listDirn = $vars->data->state->get ( 'filter_order_Dir' );
$items = $vars->data->subscription;
$j2_params = J2Store::config();
$app = JFactory::getApplication();
$subsStatusObj = \J2Store\Subscription\Helper\SubscriptionStatus::getInstance();
?>
@AshlinRejo
AshlinRejo / Discount rules v2: Get discount price of product without considering cart item quantity
Created October 13, 2022 11:53
Discount rules v2: Get discount price of product without considering cart item quantity
add_filter('advanced_woo_discount_rules_cart_item_quantity', function ($cart_item_quantity){
global $awdr_temp_qty_cal;
if($awdr_temp_qty_cal === true) $cart_item_quantity = 0;
return $cart_item_quantity;
});
add_action('woocommerce_before_add_to_cart_form', function (){
global $awdr_temp_qty_cal;
$awdr_temp_qty_cal = true;
global $product;
@AshlinRejo
AshlinRejo / Discount rule v2: Fix for displaying applied message on match free shipping
Created September 16, 2022 07:36
Discount rule v2: Fix for displaying applied message on match free shipping
add_action('woocommerce_before_cart', function(){
if(class_exists('\Wdr\App\Controllers\DiscountCalculator')){
\Wdr\App\Controllers\DiscountCalculator::getFreeshippingMethod();
}
}, 9);
@AshlinRejo
AshlinRejo / Discount rules v2: Disable strikeout for variable price
Created August 29, 2022 11:49
Discount rules v2: Disable strikeout for variable price
add_filter('advanced_woo_discount_rules_modify_price_html', function ($modify, $price_html, $product, $quantity){
if($product->is_type(array('variable'))){
$modify = false;
}
return $modify;
}, 10, 4);