Skip to content

Instantly share code, notes, and snippets.

View zorem's full-sized avatar

zorem zorem

View GitHub Profile
@zorem
zorem / set_status_shipped.php
Last active March 14, 2023 09:57
Set Order Status to Shipped(Completed) when adding tracking information with REST API
// Add this code to your theme functions.php file or a custom plugin
function ast_api_create_item_arg_filter( $args ) {
$args['status_shipped'] = 1;
return $args;
}
add_filter( 'ast_api_create_item_arg', 'ast_api_create_item_arg_filter', 10, 1 );
@zorem
zorem / exclude-country.php
Last active May 1, 2023 15:16
filter in the checkout validation for exclude country from dropdown
<?php
// Checkout Validation exclude country
add_filter('checkout_validation_exclude_country', 'checkout_validation_exclude_country');
function checkout_validation_exclude_country(){
return array('US');
}
@zorem
zorem / allowed-country.php
Last active November 25, 2022 08:43
filter in the checkout validation for allowed country from dropdown
<?php
// Checkout Validation allowed country
add_filter('checkout_validation_allowed_country', 'checkout_validation_allowed_country');
function checkout_validation_allowed_country(){
return array('AU');
}
@zorem
zorem / smswoo_additional_charsets.php
Created September 30, 2022 09:17
Filter for change the charsets type from text to unicode
add_filter( 'smswoo_additional_charsets', 'additional_charsets_for_vonage' );
function additional_charsets_for_vonage() {
return 'unicode';
}
@zorem
zorem / pending-payment-sms.php
Last active January 31, 2023 10:56
Create Pending Payment customer SMS notification
<?php
// Send sms when pending payment after 1 hour of create order.
add_action('woocommerce_new_order', function ($order_id) {
// You can change trigger time of Pending payment notifications SMS
// if you want send notifications after 2 hour you should use 2 hour multiply by 3600
as_schedule_single_action( time() + 7200, 'send_pending_payment_sms', array( $order_id ) ); // You need to change only time instead of 7200 if you want to change instead of 2 hour.
}, 10, 1);
add_action( 'init', 'send_pending_notifications', 1, 1 );
function send_pending_notifications() {
@zorem
zorem / show_est_delivery_date.php
Created January 12, 2022 07:17
Remove est delivery date from shipment status email and tracking page widget
/*
* Remove est delivery date from shipment status email and tracking page widget
*/
add_filter( 'show_est_delivery_date', 'est_delivery_date_in_email', 10, 2 );
function est_delivery_date_in_email( $bool, $provider ) {
if ( 'USPS' == $provider ) {
$bool = false;
}
return $bool;
}
<?php
/*
* slug: smswoo_clicksend
* replace slug in the code
*/
add_filter( 'smswoo_sms_provider_array', 'smswoo_sms_provider_array', 10, 1 );
function smswoo_sms_provider_array( $settings ){
$settings['smswoo_sms_provider']['options']['smswoo_clicksend'] = 'ClickSend';
// add the settings to SMS section so you can retrive SMS cridential

Shipment Tracking REST API

The shipment tracking REST API allows you to create, view, and delete individual shipment tracking. The endpoint is /wp-json/wc-ast-pro/v3/.

Shipment Tracking Properties

Attribute Type Description
tracking_id string Unique identifier for shipment tracking read-only
order_id int Unique order id required
@zorem
zorem / wc_twilio_sms_compatibility.php
Last active April 19, 2022 12:45
Add AST tracking info in customer SMS using Twilio SMS Notifications plugin
/* add AST tracking info in customer SMS using Twilio SMS Notifications plugin */
add_filter( 'wc_twilio_sms_customer_sms_before_variable_replace', 'ast_pro_wc_twilio_sms_message_replacement', 10, 2 );
if ( !function_exists( 'ast_pro_wc_twilio_sms_message_replacement' ) ) {
function ast_pro_wc_twilio_sms_message_replacement( $message, $order ) {
if ( !function_exists( 'ast_get_tracking_items' ) ) {
return;
}
@zorem
zorem / apg_sms_message_fun.php
Last active April 13, 2022 08:50
Compatibility with - WC – APG SMS Notifications. Add tracking info in SMS when order status is completed
add_filter( 'apg_sms_message', 'ast_pro_apg_sms_message_fun', 10, 2 );
/**
* Add tracking info in SMS when order status is completed
* Compatibility with - WC – APG SMS Notifications
*
*/
if ( !function_exists( 'ast_pro_apg_sms_message_fun' ) ) {
function ast_pro_apg_sms_message_fun( $message , $order_id ) {