Skip to content

Instantly share code, notes, and snippets.

View zorem's full-sized avatar

zorem zorem

View GitHub Profile
@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 / 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 / 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 / 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 / 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 ) {
@zorem
zorem / add-tracking-info-order.php
Last active April 12, 2022 04:33
Add tracking info into orders
<?php
// Check if AST PRO plugin is Installed
if ( class_exists( 'AST_Pro_Actions' ) ) {
$order_id = '123'; //Replace with your order id
$tracking_provider = 'USPS'; //Replace with your shipping provider
$tracking_number = '123123'; //Replace with your tracking number
$date_shipped = '2020-06-22'; ////Replace with your shipped date
$status_shipped = 1; // 0=no,1=shipped,2=partial shipped(if partial shipped order status is enabled)
$sku = 't-shirt,blue-jeans'; //the line item (product) SKU
@zorem
zorem / get_formatted_tracking_info.php
Last active April 11, 2022 12:49
Below is the code snippet for get formatted tracking info
<?php
// Check if function exist
if ( function_exists( 'ast_get_tracking_items' ) ) {
$order_id = 123; // Replace with your order_id
$tracking_items = ast_get_tracking_items($order_id);
foreach($tracking_items as $tracking_item){
$tracking_number = $tracking_item['tracking_number'];
@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;
}