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 August 27, 2023 14:01
WooCommerce - Automatically delete attached images after product deletion
<?php
/**
* Delete attached images after product deletion.
*
* @since 1.0.0
*
* @see wp_delete_post()
*
* @param int $post_id Post ID.
*/
@shivapoudel
shivapoudel / woocommerce-hidden-products-from-cart.php
Last active January 13, 2023 04:12
Exclude hidden products from cart area.
<?php
/**
* Filter hidden product from cart.
*
* @since 1.0.0
*
* @param bool $visibility Visibility.
* @param array $cart_item Cart item.
* @param string $cart_item_key Cart item key.
*/
@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(
@shivapoudel
shivapoudel / 1-git.md
Last active February 19, 2023 19:47
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 / 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 / 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 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 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 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 / 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