Skip to content

Instantly share code, notes, and snippets.

View vishalck's full-sized avatar

Vishal Kothari vishalck

View GitHub Profile
@vishalck
vishalck / personalize-woocommerce-thank-you-page.php
Last active May 28, 2019 18:20
Personalize the WooCommerce Thank You page
<?php
add_filter( 'the_title', 'woo_personalize_order_received_title', 10, 2 );
function woo_personalize_order_received_title( $title, $id ) {
if ( is_order_received_page() && get_the_ID() === $id ) {
global $wp;
// Get the order. Line 9 to 17 are present in order_received() in includes/shortcodes/class-wc-shortcode-checkout.php file
$order_id = apply_filters( 'woocommerce_thankyou_order_id', absint( $wp->query_vars['order-received'] ) );
$order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['key'] ) ? '' : wc_clean( $_GET['key'] ) );
@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!
}
@vishalck
vishalck / woocommerce-add-new-column-on-orders-page.php
Last active August 15, 2019 09:05
Add new column to WooCommerce Orders page
<?php
add_filter( 'manage_edit-shop_order_columns', 'MY_COLUMNS_FUNCTION' );
function MY_COLUMNS_FUNCTION( $columns ) {
$new_columns = ( is_array( $columns ) ) ? $columns : array();
unset( $new_columns[ 'order_actions' ] );
//edit this for your column(s)
//all of your columns will be added before the actions column
$new_columns['MY_COLUMN_ID_1'] = 'MY_COLUMN_1_TITLE';
@vishalck
vishalck / woocommerce-custom-thank-you-page-redirect.php
Last active June 7, 2021 12:13
Redirect to Custom Thank You page in WooCommerce
<?php
add_action( 'template_redirect', 'woo_custom_redirect_after_purchase' );
function woo_custom_redirect_after_purchase() {
global $wp;
if ( is_checkout() && !empty( $wp->query_vars['order-received'] ) ) {
wp_redirect( 'http://localhost:8888/woocommerce/custom-thank-you/' );
exit;
}
}
@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 / 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 / change-title-woocommerce-order-received-page.php
Last active January 26, 2023 21:05
Change Title of WooCommerce Thank You page
<?php
add_filter( 'the_title', 'woo_title_order_received', 10, 2 );
function woo_title_order_received( $title, $id ) {
if ( function_exists( 'is_order_received_page' ) &&
is_order_received_page() && get_the_ID() === $id ) {
$title = "Thank you for your order! :)";
}
return $title;