Skip to content

Instantly share code, notes, and snippets.

View vishalck's full-sized avatar

Vishal Kothari vishalck

View GitHub Profile
@vishalck
vishalck / show-delivery-date-on-woocommerce-orders-page.php
Created June 12, 2017 13:16
Show Order Delivery Date on WooCOmmerce Orders Page
<?php
// Delivery date & Time in list of orders on WooCommerce Edit Order page in Admin
if ( get_option( 'orddd_show_column_on_orders_page_check' ) == 'on' ) {
add_filter( 'manage_edit-shop_order_columns', array( 'orddd_filter', 'orddd_woocommerce_order_delivery_date_column' ), 20, 1 );
add_action( 'manage_shop_order_posts_custom_column', array( 'orddd_filter', 'orddd_woocommerce_custom_column_value' ), 20, 1 );
add_filter( 'manage_edit-shop_order_sortable_columns', array( 'orddd_filter', 'orddd_woocommerce_custom_column_value_sort' ) );
add_filter( 'request', array( 'orddd_filter', 'orddd_woocommerce_delivery_date_orderby' ) );
}
@vishalck
vishalck / hide_processing_order_count.php
Created June 23, 2017 13:06
Hide count of Processing orders from WooCommerce Orders menu
<?php
add_filter( 'woocommerce_include_processing_order_count_in_menu', 'exclude_processing_order_count' );
function exclude_processing_order_count( $show ) {
$show = false;
return $show;
}
@vishalck
vishalck / wc_orders_count.php
Last active June 24, 2017 11:48
wc_orders_count() from includes/wc-order-functions.php file.
<?php
/**
* Return the orders count of a specific order status.
*
* @param string $status
* @return int
*/
function wc_orders_count( $status ) {
$count = 0;
@vishalck
vishalck / empty-woocommerce-cart.php
Created August 2, 2017 20:29
Empty WooCommerce cart
<?php
/**
* Empties the cart and optionally the persistent cart too.
*
* @param bool $clear_persistent_cart (default: true)
*/
public function empty_cart( $clear_persistent_cart = true ) {
$this->cart_contents = array();
$this->reset( true );
@vishalck
vishalck / create-empty-cart-button.php
Created August 2, 2017 20:36
Add Empty Cart button on WooCommerce Cart page
<?php
add_action( 'woocommerce_after_cart_contents', array( $this, 'woo_empty_cart' ) );
/**
* Create Empty Cart button on WooCommerce cart page
*/
public function woo_empty_cart() {
global $woocommerce;
$cart_url = $woocommerce->cart->get_cart_url();
@vishalck
vishalck / initiate-empty-cart-action.php
Created August 2, 2017 20:42
Initiate WooCommerce Empty Cart Action
<?php
public function woo_empty_cart_action() {
global $woocommerce;
if ( isset( $_REQUEST[ 'emptycart' ] ) && $_REQUEST[ 'emptycart' ] == 'yes' ) {
$woocommerce->cart->empty_cart();
}
}
@vishalck
vishalck / woocommerce-hide-prices-shop-category.php
Created January 26, 2019 10:16
How to Hide Prices on WooCommerce Shop and Category Pages
<?php
/**
* Snippet 1: Hide prices on all categories
* Created by: Tyche Softwares
*/
function tyches_hide_prices_on_all_categories( $price, $product ) {
if ( is_tax() ) {
return ''; // Empty string = no price!
}