Skip to content

Instantly share code, notes, and snippets.

View shivapoudel's full-sized avatar
🎯
Focusing

Shiva Poudel shivapoudel

🎯
Focusing
View GitHub Profile
@shivapoudel
shivapoudel / functions.php
Last active January 18, 2018 10:33
WooCommerce - Automatically add product to cart on visit
<?php // Do not include this if already open!
/**
* Code goes in theme functions.php.
*/
if ( class_exists( 'WooCommerce' ) ) {
add_action( 'template_redirect', 'wc_auto_add_product_to_cart' );
}
/**
@shivapoudel
shivapoudel / functions.php
Created December 17, 2016 17:26
WooCommerce - Allow rendering of checkout and account pages in iframes
<?php // Do not include this if already open!
/**
* Code goes in theme functions.php.
*/
add_action( 'after_setup_theme', 'wc_remove_frame_options_header', 11 );
/**
* Allow rendering of checkout and account pages in iframes.
*/
@shivapoudel
shivapoudel / woocommerce.md
Last active October 27, 2017 17:34
Transactional and Notificational Emails trigger hooks :)

Order Statuses:

'wc-pending'    => _x( 'Pending payment', 'Order status', 'woocommerce' ),
'wc-processing' => _x( 'Processing', 'Order status', 'woocommerce' ),
'wc-on-hold'    => _x( 'On hold', 'Order status', 'woocommerce' ),
'wc-completed'  => _x( 'Completed', 'Order status', 'woocommerce' ),
'wc-cancelled'  => _x( 'Cancelled', 'Order status', 'woocommerce' ),
'wc-refunded'   => _x( 'Refunded', 'Order status', 'woocommerce' ), // Excluded
'wc-failed' =&gt; _x( 'Failed', 'Order status', 'woocommerce' ), // Excluded
@shivapoudel
shivapoudel / functions.php
Created January 12, 2018 06:24
WP REST API - Modify API base URL prefix.
<?php // Do not include this if already open!
/**
* Code goes in theme functions.php.
*/
add_filter( 'rest_url_prefix', 'custom_rest_url_prefix' );
/**
* Modify url base from 'wp-json' to 'api' prefix.
*/
@shivapoudel
shivapoudel / functions.php
Created January 17, 2018 09:37
WooCommerce - Enable REST API permissions check
<?php // Do not include this if already open!
/**
* Code goes in theme functions.php.
*/
add_filter( 'woocommerce_rest_check_permissions', '__return_true' );
@shivapoudel
shivapoudel / functions.php
Created February 3, 2018 09:14
WooCommerce - Prevent order view link being triggered on row click
<?php // Do not include this if already open!
/**
* Code goes in theme functions.php.
*/
if ( class_exists( 'WooCommerce' ) ) {
add_action( 'post_class', 'wc_order_post_class', 20, 3 );
}
/**
@shivapoudel
shivapoudel / functions.php
Created April 12, 2018 08:37
WooCommerce - Remove all filters for formatted order total
<?php // Do not include this if already open!
/**
* Code goes in theme functions.php.
*/
add_action( 'plugins_loaded', 'remove_wc_get_formatted_order_total_filters' );
/**
* Remove all filters for WC formatted order total.
*/
@shivapoudel
shivapoudel / functions.php
Created April 13, 2018 06:54
WooCommerce - Change order button text strings
<?php // Do not include this if already open!
/**
* Code goes in theme functions.php.
*/
add_filter( 'gettext', 'custom_order_button_strings', 20 );
/**
* Change order button text strings.
*
@shivapoudel
shivapoudel / 1-git.md
Last active March 14, 2026 18:13
WSL setup for Ubuntu environment.

Installing Git on WSL

Git appears to come as standard as part of the WSL install. You can test this by running:

$ git --version

If for some reason Git is not installed then you can simply pull it down:

@shivapoudel
shivapoudel / action-schedular.php
Last active January 29, 2022 08:49
Action Schedular queue in loop
<?php
function args_update() {
$loop = 0;
$args = array(
'name',
'surname'
);
foreach ( $args as $arg ) {
WC()->queue()->schedule_single(