Skip to content

Instantly share code, notes, and snippets.

Avatar

Vishal Kothari ashokrane

View GitHub Profile
@ashokrane
ashokrane / shorten-woocommerce-product-name-in-abandon-cart-recovery-emails.php
Created Jan 24, 2018
How to shorten WooCommerce product name in Abandon cart recover email notification
View shorten-woocommerce-product-name-in-abandon-cart-recovery-emails.php
<?php
add_filter( 'wcap_product_name', 'shorten_product_name_in_abandon_cart_emails', 10, 1 );
function shorten_product_name_in_abandon_cart_emails( $item_name ) {
if ( 'Rent a bicycle' == $item_name ) {
$item_name = 'Rent a bicy..';
}
return $item_name;
}
@ashokrane
ashokrane / show_custom_woocommerce_thank_you_by_variation_id.php
Last active Mar 13, 2018
Redirect to custom WooCommerce Thank You page based on product attribute id (variation id)
View show_custom_woocommerce_thank_you_by_variation_id.php
<?php
add_action( 'woocommerce_thankyou', 'redirect_product_attribute_based', 1 );
function redirect_product_attribute_based( $order_id ) {
$order = wc_get_order( $order_id );
foreach( $order->get_items() as $item ) {
// Add whatever variation id you want below here
if ( isset( $item[ 'variation_id' ] ) && $item[ 'variation_id' ] == 446 ) {
// change below to the URL that you want to send your customer to
wp_redirect( 'http://yoururl.com/custom-thank-you/' );
@ashokrane
ashokrane / show_custom_text_woocommerce_thank_you_by_variation_id.php
Created Mar 13, 2018
Print custom text on WooCommerce Thank You page based on product attribute id (variation id)
View show_custom_text_woocommerce_thank_you_by_variation_id.php
<?php
add_action( 'woocommerce_thankyou', 'show_custom_text_by_variation_id', 1 );
function show_custom_text_by_variation_id( $order_id ) {
$order = wc_get_order( $order_id );
foreach( $order->get_items() as $item ) {
// Add whatever variation id you want below here. My attributes are Cheddar, Mozarella & Swiss
if ( isset( $item[ 'variation_id' ] ) && $item[ 'variation_id' ] == 446 ) {
echo 'Thank you for choosing Cheddar cheese. Enjoy your Sandwich!<br/>';
}
@ashokrane
ashokrane / edd-extra-api-endpoints.php
Last active Jan 13, 2019
Fetch sales & earnings (or refunded sales & earnings) for different products, date-wise - for Easy Digital Downloads
View edd-extra-api-endpoints.php
<?php
/*
Plugin Name: Extra API Endpoints for Easy Digital Downloads
Plugin URI: https://www.tychesoftwares.com
Description: This plugin allows to fetch some additional statistics for your Easy Digital Downloads store.
Author: Tyche Softwares
Version: 1.0
Author URI: http://www.tychesoftwares.com/about
Contributor: Tyche Softwares, http://www.tychesoftwares.com/
*/
@ashokrane
ashokrane / add-delivery-date-field.php
Created Feb 22, 2019
Add delivery date field on WooCommerce checkout page
View add-delivery-date-field.php
<?php
add_action( 'woocommerce_after_checkout_billing_form', 'display_extra_fields_after_billing_address' , 10, 1 );
function display_extra_fields_after_billing_address () {
_e( "Delivery Date: ", "add_extra_fields");
?>
<br>
<input type="text" name="add_delivery_date" class="add_delivery_date" placeholder="Delivery Date">
<?php
}
@ashokrane
ashokrane / strtotime_returning_blank.php
Created Feb 23, 2019
strtotime() returning blank or empty timestamp
View strtotime_returning_blank.php
<?php
echo strtotime( '21-02-2019 10:0' ); // 1550743200
echo '<br>' . strtotime( '21-02-2019 10:00' ); // 1550743200
echo '<br>' . strtotime( '21-02-2019 100' ); // blank, thereby results in a date of 1-1-1970 when used in date()
echo '<br>' . strtotime( '21-02-2019 1000' ); // 1550743200
@ashokrane
ashokrane / woocommerce-specific-date-filters-by-variations.php
Created Mar 30, 2019
Sample functions for specific date filters in Order Delivery Date Pro plugin
View woocommerce-specific-date-filters-by-variations.php
<?php
add_filter( 'orddd_global_specific_delivery_dates', 'ts_add_global_specific_delivery_charges_by_variations', 10, 4 );
function ts_add_global_specific_delivery_charges_by_variations( $specific_fees, $specific_date, $specific_date_charges, $specific_charges_label ) {
global $woocommerce;
$found = false;
// determine if selected variation is in cart or not
@ashokrane
ashokrane / overwrite-step-minute-increment.php
Created Mar 30, 2019
Overwrite the minute increment from 5 minutes to anything else in Order Delivery Datea plugin
View overwrite-step-minute-increment.php
<?php
add_filter( 'orddd_time_slider_minute_step', 'ts_orddd_overwrite_minute_increment', 10, 1 );
function ts_orddd_overwrite_minute_increment( $step_minute ) {
$step_minute = 15;
return $step_minute;
}
@ashokrane
ashokrane / woocommerce-order-data-via-webhook.json
Last active Jul 19, 2019
WooCommerce Order data sent via order.created webhook action
View woocommerce-order-data-via-webhook.json
{
"id":1194,
"parent_id":0,
"number":"1194",
"order_key":"wc_order_YzXqv7u79WjZS",
"created_via":"checkout",
"version":"3.6.4",
"status":"on-hold",
"currency":"USD",
"date_created":"2019-07-20T02:08:30",
@ashokrane
ashokrane / code2.gs
Created Jul 19, 2019
Google apps script for integration of WooCommece orders to Google sheets.
View code2.gs
//this is a function that fires when the webapp receives a GET request
function doGet(e) {
return HtmlService.createHtmlOutput("request received");
}
//this is a function that fires when the webapp receives a POST request
function doPost(e) {
var myData = JSON.parse([e.postData.contents]);
var order_number = myData.number;
var order_created = myData.date_created;
You can’t perform that action at this time.