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 / Custom code for Email customizer - woocommerce-local-pickup-time-select
Last active October 4, 2018 07:41
Custom code for Email customizer - woocommerce-local-pickup-time-select
<?php
/**
* Custom code shortcode
*
* This template can be overridden by copying it to yourtheme/plugin-folder-name/woo_mail/custom_code.php.
* @var $order WooCommerce order
* @var $email_id WooCommerce email id (new_order, cancelled_order)
* @var $sent_to_admin WooCommerce email send to admin
* @var $plain_text WooCommerce email format
* @var $email WooCommerce email object
@AshlinRejo
AshlinRejo / Remove subtotal and payment method from order table(in emails) through template override - Email Customizer
Last active October 4, 2018 07:41
Remove subtotal and payment method from order table(in emails) through template override - Email Customizer
<?php
/**
* Order details table shown in emails.
*
* This template can be overridden by copying it to yourtheme/woocommerce/emails/email-order-details.php.
*
* HOWEVER, on occasion WooCommerce 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 the readme will list any important changes.
@AshlinRejo
AshlinRejo / For displaying discounted price in discount table - Woo Discount Rules
Last active October 4, 2018 07:41
For displaying discounted price in discount table - Woo Discount Rules
<?php
/**
* List matched Rules in Table format
*
* This template can be overridden by copying it to yourtheme/plugin-folder-name/discount-table.php
*/
if (!defined('ABSPATH')) exit; // Exit if accessed directly
if (!isset($table_data) || empty($table_data)) return false;
$base_config = (is_string($data)) ? json_decode($data, true) : (is_array($data) ? $data : array());
@AshlinRejo
AshlinRejo / Add the below code in template function.pho to support WooCommerce Wholesale Prices Premium - Rymera Web Co with Woo Discount rules
Last active October 4, 2018 07:41
Add the below code in template function.pho to support WooCommerce Wholesale Prices Premium - Rymera Web Co with Woo Discount rules
if(!function_exists('woo_discount_rules_remove_event_woocommerce_before_calculate_totals_for_wholesale_prices')){
/**
* Compatible for Wholesale price
* */
function woo_discount_rules_remove_event_woocommerce_before_calculate_totals_for_wholesale_prices($remove_event){
return true;
}
}
add_filter('woo_discount_rules_remove_event_woocommerce_before_calculate_totals', 'woo_discount_rules_remove_event_woocommerce_before_calculate_totals_for_wholesale_prices');
@AshlinRejo
AshlinRejo / Woo Discout Rules: For disable the variant strikeout through ajax
Last active October 4, 2018 07:40
Woo Discout Rules: For disable the variant strikeout through ajax
if(!function_exists('woo_discount_rules_run_variation_strikeout_through_ajax_method')){
function woo_discount_rules_run_variation_strikeout_through_ajax_method($do_ajax){
return false;
}
}
add_filter('woo_discount_rules_run_variation_strikeout_through_ajax', 'woo_discount_rules_run_variation_strikeout_through_ajax_method');
if(!function_exists('woo_discount_rules_run_variation_strike_out_with_ajax_method')){
/**
@AshlinRejo
AshlinRejo / Woo Discount Rules: To handle specific attribute based on all selected attributes
Last active October 4, 2018 07:40
Woo Discount Rules: To handle specific attribute based on all selected attributes
if(!function_exists('woo_discount_rules_price_rule_check_in_all_selected_attributes_method')){
/**
* Rule based on all attributes
*
* @param boolean $in_all_attribute
* @param int $rule_order_id
* @return boolean
* */
function woo_discount_rules_price_rule_check_in_all_selected_attributes_method($in_all_attribute, $rule_order_id){
return true;
@AshlinRejo
AshlinRejo / Woo Discount Rules: For applying discount only for main product while using Woocommerce product addon
Last active May 21, 2020 02:33
Woo Discount Rules: For applying discount only for main product while using Woocommerce product addon
if(!function_exists('woo_discount_rules_has_price_override_method')){
function woo_discount_rules_has_price_override_method($has_price_override, $product, $on_apply_discount){
if($on_apply_discount == 'on_apply_discount') $has_price_override = true;
return $has_price_override;
}
}
add_filter('woo_discount_rules_has_price_override', 'woo_discount_rules_has_price_override_method', 10, 3);
function woo_discount_rules_price_rule_final_amount_applied_method($discountedPrice, $price, $discount, $additionalDetails, $product, $product_page){
if($discountedPrice < 0) $discountedPrice = 0;
@AshlinRejo
AshlinRejo / Woo Discount Rules: If some plugin override the price
Last active October 4, 2018 07:39
Woo Discount Rules: If some plugin override the price
if(!function_exists('woo_discount_rules_remove_event_woocommerce_before_calculate_totals_method')){
function woo_discount_rules_remove_event_woocommerce_before_calculate_totals_method($remove_event){
return true;
}
}
add_filter('woo_discount_rules_remove_event_woocommerce_before_calculate_totals', 'woo_discount_rules_remove_event_woocommerce_before_calculate_totals_method');
if(!function_exists('woo_discount_rules_has_price_override_method')){
function woo_discount_rules_has_price_override_method($hasPriceOverride, $product){
return true;
@AshlinRejo
AshlinRejo / Woo Discount Rules: Support Woocommerce Brands - Brands loads in category while create rules
Last active February 8, 2019 05:23
Woo Discount Rules: Support Woocommerce Brands - Brands loads in category while create rules
function woo_discount_rules_accepted_taxonomy_for_category_method($taxonomy){
$taxonomy[] = 'product_brand';
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){
$brands = get_the_terms( $product_id, 'product_brand' );
if(!empty($brands)){
@AshlinRejo
AshlinRejo / Woo Discount Rules: Skip some product from bogo like free product when applying second time
Last active October 4, 2018 07:39
Woo Discount Rules: Skip some product from bogo like free product when applying second time
if(!function_exists('woo_discount_rules_skip_discount_for_free_product_method')){
function woo_discount_rules_skip_discount_for_free_product_method($skip_free_product, $cart_item){
$_product = $cart_item['data'];
//Example
if(!empty($_product)){
$price = $_product->get_price();
if($price == 0){
if(!empty($cart_item['thwepo_options'])) return true;
}
}