Skip to content

Instantly share code, notes, and snippets.

View zorem's full-sized avatar

zorem zorem

View GitHub Profile
@zorem
zorem / change_tracking_provider.php
Last active February 1, 2021 12:19
Replace tracking provider
<?php
// Add this code to your theme functions.php file or a custom plugin
function ast_api_create_item_arg_filter( $args ) {
if( $args['tracking_provider'] == 'dhlglobalmail' ){
$args['tracking_provider'] = 'dhl-express';
}
return $args;
}
@zorem
zorem / remove_tracking_info_invoice_pdf.php
Created July 23, 2019 11:35
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' ];
@zorem
zorem / create_delivered_status.php
Last active October 1, 2020 18:11
From this code snippet you can create custom order status delivered
<?php
// Add this code to your theme functions.php file or a custom plugin
add_action('init', 'register_order_status');
//add status after completed
add_filter('wc_order_statuses', 'add_delivered_to_order_statuses');
//Custom Statuses in admin reports
add_filter('woocommerce_reports_order_statuses', 'include_custom_order_status_to_reports', 20, 1);
// for automate woo to check order is paid
add_filter('woocommerce_order_is_paid_statuses', 'delivered_woocommerce_order_is_paid_statuses');
@zorem
zorem / add_tracking_info_orders.php
Last active October 20, 2020 11:20
Endpoint – Create a shipment tracking
//With this endpoint you can add new tracking info to orders:
POST /wp-json/wc-ast/v3/orders/<order_id>/shipment-trackings/
curl -X POST https://your-domain.com/wp-json/wc-ast/v3/orders/<order_id>/shipment-trackings
-u consumer_key:consumer_secret
-H "Content-Type: application/json"
-d '{
"tracking_provider": "Fedex",
"tracking_number": "12345678",
@zorem
zorem / list_all_shipment_trackings.php
Last active September 22, 2020 11:09
With this endpoint you can list all tracking info added to an order. You will need to pass order id and you’ll get respond with array of tracking numbers added to that order,
GET /wp-json/wc-ast/v3/orders/<order_id>/shipment-trackings/
curl -X GET https://your-domain.com/wp-json/wc-ast/v3/orders/<order_id>/shipment-trackings
-u consumer_key:consumer_secret
//JSON response:
{
"tracking_id": "feb9bde4475fda92cc9408607b7ecb66",
"tracking_provider": "Fedex",
@zorem
zorem / delete_shipment_tracking.php
Last active September 22, 2020 11:45
You can delete tracking numbers from orders, you will need to pass the order id and the tracking_id for this tracking number:
DELETE /wp-json/wc-ast/v3/orders/<order_id>/shipment-trackings/
curl -X DELETE https://your-domain.com/wp-json/wc-ast/v3/orders/<order_id>/shipment-trackings/fa61d174a05d2f34323b51d92823947d
-u consumer_key:consumer_secret
//response example:
"Tracking ID: fa61d174a05d2f34323b51d92823947d"
@zorem
zorem / login-redirect.php
Created August 5, 2019 09:21
Using this code snippet you can redirect to custom page after login
<?php
add_filter( "wcalr_login_redirect", "wcalr_login_redirect_link", 10, 1);
function wcalr_login_redirect_link($link){
$link = get_home_url();
return $link;
}
@zorem
zorem / register-redirect.php
Created August 5, 2019 09:25
Using this code snippet you can redirect to custom page after register
<?php
add_filter( "wcalr_register_redirect", "wcalr_register_redirect_link", 10, 1);
function wcalr_register_redirect_link($link){
$link = get_home_url();
return $link;
}
@zorem
zorem / after-login-registration.php
Created August 5, 2019 09:31
Just use below snippet by using this snippet you can maintaining login status after successful login. You just need to add this snippet code in a function.php file if you want to maintain login status.
add_action( "wcalr_after_login", 'wcalr_after_login_func', 10, 1 );
function wcalr_after_login_func($user_signon){
wp_set_current_user($user_signon->ID);
wp_set_auth_cookie($user_signon->ID);
}
@zorem
zorem / .htaccess
Created August 12, 2019 13:58
This means in your store there HTTP request is blocked, this is because of server configuration. You'll need to edit your .htaccess file by adding the following code above # BEGIN WordPress :
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
</IfModule>