Skip to content

Instantly share code, notes, and snippets.

View iamsathyaseelan's full-sized avatar

Sathyaseelan iamsathyaseelan

View GitHub Profile
@iamsathyaseelan
iamsathyaseelan / sync_email_on_pageload.php
Last active January 29, 2021 08:41
sync email when email found
<?php
add_action("wp_footer", function () {
if (is_checkout()) {
echo '<script>jQuery(document).ready(function ($) {
setTimeout(function () {
let emailField = $("#billing_email");
if (emailField.length > 0) {
emailField.trigger("change");
}
}, 1000);
@iamsathyaseelan
iamsathyaseelan / show_retainful_referral_in_home_And_checkout.php
Last active January 27, 2021 10:08
Show the Retainful refferal window in particiular pages (Home and checkout pages)
<?php
add_action('wp_footer',function(){
$display = "none";
if(is_front_page() || is_checkout()){
$display = "block";
}
echo "<style>
.rtl-launcher{
display:{$display} !important;
}
@iamsathyaseelan
iamsathyaseelan / order_items.php
Created January 20, 2021 06:03
Template override for woocommerce email customizer plus to solve the duplication of cart for two times
<div class="email-product-list" style="padding: 15px 25px;">
<?php
/**
* Order details table shown in emails.
*
* 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.
*/
@iamsathyaseelan
iamsathyaseelan / auto-trigger-email-change.php
Created January 12, 2021 07:20
auto trigger change in email field on page load to solve the issue in capturing loggedin user's details
<?php
add_filter("wp_footer",function(){
?>
<script>
document.addEventListener("DOMContentLoaded", function () {
let emailField = jQuery("input#billing_email");
if (emailField.length > 0) {
emailField.trigger("change");
}
});
<!doctype html>
<html lang="en">
<head>
<title>Simple todo list</title>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"
integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>
@iamsathyaseelan
iamsathyaseelan / get_order_payemt_url.php
Created December 4, 2020 05:58
email customizer payment url
<?php
add_filter('woocommerce_email_customizer_plus_short_code_values', function ($short_codes, $order, $args, $sample) {
/**
* @var $order \WC_Order
*/
$payment_url = "";
if (method_exists($order, 'get_checkout_payment_url')) {
$payment_url = $order->get_checkout_payment_url();
}
$short_codes['order']['payment_url'] = $payment_url;
@iamsathyaseelan
iamsathyaseelan / change_referral_url.php
Last active December 4, 2020 04:08
change referral login url
<?php
add_action("rnoc_referral_login_url",function($login_url){
return "https://www.happynappy.ie/wp-login.php";
});
add_action("rnoc_referral_register_url",function($register_url){
return "https://www.happynappy.ie/wp-login.php?action=register&redirect_to=https://www.happynappy.ie/my-account/";
});
@iamsathyaseelan
iamsathyaseelan / wecp_get_customer_role.php
Created September 24, 2020 05:57
email customizer plus - get customer role shortcode
add_filter('woocommerce_email_customizer_plus_additional_short_codes_list', 'wecpLoadAdditionalShortCodes', 10, 3);
function wecpLoadAdditionalShortCodes($additional_short_codes){
$additional_short_codes['customer.role'] = 'get customer role';
return $additional_short_codes;
}
add_filter('woocommerce_email_customizer_plus_short_code_values', 'wecpLoadAdditionalData', 10, 4);
function wecpLoadAdditionalData($short_codes, $order, $args, $sample){
if (is_array($short_codes)) {
$user_role = '';
@iamsathyaseelan
iamsathyaseelan / order_items.php
Last active September 16, 2020 10:51
adding purchase note in order email for email customizer plus
<div class="email-product-list" style="padding: 15px 25px;">
<?php
/**
* Order details table shown in emails.
*
* 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.
*/
@iamsathyaseelan
iamsathyaseelan / split-order-items-table.php
Created August 3, 2020 12:34
split order item details in email customizer plus into 2 table
<div class="email-product-list" style="padding: 15px 25px;">
<h6>Product details:</h6>
<?php
/**
* Order details table shown in emails.
*
* 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.