Skip to content

Instantly share code, notes, and snippets.

View the-sufi's full-sized avatar
🏠
Working from home

the-sufi

🏠
Working from home
View GitHub Profile
@the-sufi
the-sufi / woo-show-coupon-details-in-order-email.php
Created April 6, 2020 01:24
WooCommerce - show coupon code & description in order email
<?php
function dctit_add_coupon_to_email( $order ) {
$coupons = $order->get_items('coupon');
foreach ($coupons as $item_id => $item) {
$coupon = new WC_Coupon( $item['name'] );
$post = get_post($coupon->id);
echo "<p class='coupon-used'><span class='coupon-name'><b>Coupon: " . $item['name'] . "</b></span></p>";
echo "<p><span class='coupon-description'>" . $post->post_excerpt . "</span></p>";
}
@the-sufi
the-sufi / woo-orders-auto-complete.php
Last active April 6, 2020 01:25
WooCommerce - Automactically Mark Orders as Complete
<?php
/**
* Auto Complete all WooCommerce orders.
*/
function dctit_custom_woocommerce_auto_complete_order( $order_id ) {
if ( ! $order_id ) {
return;
}
$order = wc_get_order( $order_id );
@the-sufi
the-sufi / wp-auto-flush-w3tc.php
Last active April 6, 2020 01:22
WordPress - Weekly Flush all caches of W3 Total Cache Automatically
<?php
/** Flush all caches of W3TC
* Weekly basis
*/
//add weekly shcedule to wp cron
function dctit_cron_add_weekly( $schedules ) {
//adds once weekly to the existing schedules.
$schedules['weekly'] = array(
'interval' => 604800,