Skip to content

Instantly share code, notes, and snippets.

@gaurav-zorem
gaurav-zorem / create_updated_tracking_status.php
Created May 5, 2025 05:16
From this code snippet you can create custom order status Updated Tracking
<?php
// Register the custom order status
add_action('init', 'register_updated_tracking_status');
// Add the new status after 'completed'
add_filter('wc_order_statuses', 'add_updated_tracking_to_order_statuses');
// Include the new status in WooCommerce reports
add_filter('woocommerce_reports_order_statuses', 'include_updated_tracking_status_to_reports');
@gaurav-zorem
gaurav-zorem / woocommerce-custom-shipped-status.php
Created April 12, 2024 05:15
"Adds a custom 'Shipped' order status to WooCommerce, integrating it with order lists, reports, and marking it as paid."
<?php
// Add this code to your theme functions.php file or a custom plugin
add_action('init', 'register_shipped_order_status');
// Add status after completed
add_filter('wc_order_statuses', 'add_shipped_to_order_statuses');
// Custom Statuses in admin reports
add_filter('woocommerce_reports_order_statuses', 'include_shipped_order_status_to_reports', 20, 1);
// For automate woo to check order is paid
add_filter('woocommerce_order_is_paid_statuses', 'shipped_woocommerce_order_is_paid_statuses');
@gaurav-zorem
gaurav-zorem / ast_ali2woo_shipping_provider.php
Created June 19, 2023 11:10
Replace the shipping provider when syncing tracking from Aliexpress
function ast_ali2woo_shipping_provider_callback( $shipping_provider ) {
return 'Cainiao';
}
add_filter( 'ast_ali2woo_shipping_provider', 'ast_ali2woo_shipping_provider_callback' );
@gaurav-zorem
gaurav-zorem / ast_ali2woo_shipping_provider.php
Created May 31, 2023 11:34
Replace the adding provider when sync tracking numbers from aliexpress orders
function ast_ali2woo_shipping_provider_callback( $shipping_provider ) {
return 'Cainiao';
}
add_filter( 'ast_ali2woo_shipping_provider', 'ast_ali2woo_shipping_provider_callback' );
@gaurav-zorem
gaurav-zorem / s2w_shopify_order_number.php
Created May 29, 2023 06:04
Get the order id from order number for S2W - Import Shopify to WooCommerce plugin
add_filter( 'ast_formated_order_id', 'ast_formated_order_id', 10, 2 );
function ast_formated_order_id( $order_id , $original_order_id ) {
if ( class_exists( 'S2W_IMPORT_SHOPIFY_TO_WOOCOMMERCE' ) ) {
$query_args = array(
'numberposts' => 1,
'meta_key' => '_s2w_shopify_order_number',
'meta_value' => $order_id,
'post_type' => 'shop_order',
'post_status' => 'any',
@gaurav-zorem
gaurav-zorem / child-theme.css
Created May 23, 2023 13:44
Create a Child Theme
/*Theme Name: Child Theme twentyeleven (required)
Theme URI: http: //example.com/ (optional)
Description: Child theme for the Twenty Eleven theme (optional)
Author: Your name here (optional)
Author URI: http: //example.com/about/ (optional)
Template: twentyeleven (required)Version: 0.1.0 (optional)
@gaurav-zorem
gaurav-zorem / shortcode.php
Created May 23, 2023 13:42
Create WordPress Shortcode to display Websites Screenshot Thumbnails
function wpr_snap($atts, $content = null) {
extract(shortcode_atts(array(
"snap" => 'http://s.wordpress.com/mshots/v1/',
"url" => 'http://www.internoetics.com',
"alt" => 'Image text',
"w" => '400', // width
"h" => '300' // height
), $atts));
$img = '<img src="' . $snap . '' . urlencode($url) . '?w=' . $w . '&h=' . $h . '" alt="' . $alt . '">';
@gaurav-zorem
gaurav-zorem / assign-user-in-guest-order.php
Created May 23, 2023 13:39
Link WooCommerce Guest Orders to Customer Account
//assign user in guest order
add_action( 'woocommerce_new_order', 'action_woocommerce_new_order', 10, 1 );
function action_woocommerce_new_order( $order_id ) {
$order = new WC_Order($order_id);
$user = $order->get_user();
if( !$user ){
//guest order
$userdata = get_user_by( 'email', $order->get_billing_email() );
if(isset( $userdata->ID )){
@gaurav-zorem
gaurav-zorem / change_tracking_provider.php
Last active July 23, 2019 10:37
Change tracking provider
<?php
// Add this code to your theme functions.php file or a custom plugin
add_filter( 'ast_api_create_item_arg', 'ast_api_create_item_arg_filter', 10, 1 );
function ast_api_create_item_arg_filter( $args ) {
if( is_numeric( $args['tracking_number'] ) && $args['tracking_provider'] == 'ups' ){
$args['tracking_provider'] = 'usps';
}
return $args;
}
@gaurav-zorem
gaurav-zorem / remove_tracking_info_invoice_pdf.php
Last active July 23, 2019 10:37
Do not show information of the plugin “Shipment Tracking” in invoice PDFs
<?php
// Add this code to your theme functions.php file or a custom plugin
if ( class_exists( 'zorem_woocommerce_advanced_shipment_tracking' ) ) {
add_action( 'wp_wc_invoice_pdf_start_template', function() {
$tracking_actions = $GLOBALS[ 'WC_advanced_Shipment_Tracking' ];
remove_action( 'woocommerce_email_before_order_table', array( $tracking_actions, 'email_display' ), 0, 4 );
});
add_action( 'wp_wc_invoice_pdf_end_template', function() {
$tracking_actions = $GLOBALS[ 'WC_advanced_Shipment_Tracking' ];