Skip to content

Instantly share code, notes, and snippets.

View zorem's full-sized avatar

zorem zorem

View GitHub Profile
@zorem
zorem / wp_user_dashboard_setup.php
Last active October 22, 2020 14:13
Remove WooCommerce Dashboard Status, reports and analytics for shop manager user role
<?php
/*
* https://www.zorem.com/hide-sales-data-from-the-woocommerce-shop-manager-role/
*
* Remove WooCommerce Dashboard Status for shop manager
*/
function remove_dashboard_widgets() {
if ( current_user_can( 'shop_manager' ) ) {
// remove WooCommerce Dashboard Status
remove_meta_box( 'woocommerce_dashboard_status', 'dashboard', 'normal' );
@zorem
zorem / get_ast_provider_name.php
Last active October 16, 2020 08:29
Code snippet for change the Style of Provider name in Orders List page
add_filter( 'get_ast_provider_name', 'get_ast_provider_name_filter', 10, 2 );
function get_ast_provider_name_filter( $tracking_provider, $results ) {
if ($tracking_provider == 'USPS' ) {
return "<span style='color:blue'>".$tracking_provider."</span>";
}
return $tracking_provider;
}
@zorem
zorem / trackship_tracking_event_description
Last active September 27, 2021 13:47
Code snippet for modify tracking event description and tracking event location for TrackShip tracking page
/*
* Trackship.info
* tracking event description modify
*/
add_filter( 'trackship_tracking_event_description', 'trackship_tracking_event_description', 10, 1 );
function trackship_tracking_event_description( $message ){
$search = array(
"China,",
"China",
"Rusia",
@zorem
zorem / ast_email_order_items_args.php
Created September 18, 2020 08:52
We added filter for email order items arguments for shipment status email. If user want to show product image in order items use below code and put in functions.php of your theme.
add_filter( 'ast_email_order_items_args', 'ast_email_order_items_args_callback' );
function ast_email_order_items_args_callback( $args ) {
$args['show_image'] = true;
return $args;
}
@zorem
zorem / tracking_info_args.php
Last active July 17, 2020 09:02
Filter for update tracking information when add tracking from orders list and single order page
add_filter('tracking_info_args','tracking_info_args_fun',10,2);
function tracking_info_args_fun($args,$order_id){
if($args['tracking_provider'] == 'australia-post'){
$args['tracking_number'] = '0003006985494006020994';
}
return $args;
}
@zorem
zorem / ast_trigger_ts_status_change.php
Last active June 23, 2020 07:04
Code snippet for send SMS using Twilio SMS Notifications plugin when shipments status change from TrackShip
<?php
add_action( 'ast_trigger_ts_status_change', 'ast_send_status_change_sms_twillio', 10, 3 );
function ast_send_status_change_sms_twillio($order_id, $old_status, $new_status){
$wc_ast_api_key = get_option('wc_ast_api_key');
$blog_title = get_bloginfo();
if ( !class_exists( 'WC_Advanced_Shipment_Tracking_Actions' ) ) {
return;
@zorem
zorem / woocommerce_payment_complete_order_status.php
Created May 13, 2020 13:04
The function is for change order status to competed if order is virtual and downloadable
<?php
add_filter( 'woocommerce_payment_complete_order_status', 'virtual_order_payment_complete_order_status', 10, 4 );
/*
* move processing to completed
*/
function virtual_order_payment_complete_order_status( $order_status, $order_id ) {
$order = wc_get_order( $order_id );
if ( 'processing' == $order_status ) {
$virtual_order = null;
@zorem
zorem / bulk_actions_edit_shop_order.php
Last active October 9, 2020 13:03
Add your custom order status in bulk action dropdown
<?php
add_filter( 'bulk_actions-edit-shop_order', 'add_bulk_actions_change_order_status' , 50, 1 );
function add_bulk_actions_change_order_status($bulk_actions){
// Replace 'my-custom-status' with your custom order status slug
// Replace 'My Custom Status' with your custom order status name
$bulk_actions['mark_my-custom-status'] = __( 'Change status to My Custom Status', 'woocommerce' );
return $bulk_actions;
}
@zorem
zorem / change-message-of-remove cart-item.php
Last active October 20, 2020 11:54
How To Add Custom Message For Remove Cart Item
/**
* change message of remove cart item in woocommerce
**/
function change_remove_cart_item_message($message,$product) {
return sprintf( __( '%s has been removed from your cart because it can no longer be purchased. Please contact us if you need assistance.', 'woocommerce' ), $product->get_name() );
}
add_filter( 'cbr_cart_item_removed_message', 'change_remove_cart_item_message', 10, 2 );
@zorem
zorem / redirect-404-error-page.php
Last active May 13, 2020 10:59
How To Change Redirect The 404 Error Page
/**
* redirect 404 error page.
*/
function redirect_404_to_otherpage($url){
return $url = get_permalink('page id');
}
add_filter( 'cbr_redirect_page_dir', 'redirect_404_to_otherpage', 10, 1 );