This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Function to handle HTTP POST requests | |
function doPost(e) { | |
if (e && e.postData) { | |
// Parse the payload content | |
var myData = JSON.parse(e.postData.contents); | |
// Check if the order status indicates a completed payment | |
if (myData.status === 'completed') { | |
// Extract additional order details | |
var order_number = myData.number; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'woocommerce_package_rates', 'ts_hide_specific_shipping_method', 10, 2 ); | |
function ts_hide_specific_shipping_method( $rates, $package ) { | |
// Define the shipping rate IDs to hide for guests | |
$targeted_rate_ids_guest = array( | |
'flat_rate:4', // Flat rate shipping method for guests | |
// Free shipping method for guests | |
); | |
// Define the shipping rate IDs to hide for subscribers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wc_qty_add_product_field() { | |
echo '<div class="options_group">'; | |
woocommerce_wp_text_input( | |
array( | |
'id' => '_wc_min_qty_product', | |
'label' => __( 'Minimum Quantity', 'woocommerce-max-quantity' ), | |
'placeholder' => '', | |
'desc_tip' => 'true', | |
'description' => __( 'Optional. Set a minimum quantity limit allowed per order. Enter a number, 1 or greater.', 'woocommerce-max-quantity' ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('init', 'start_session', 1); | |
function start_session() { | |
if (!session_id()) { | |
session_start(); | |
} | |
} | |
// Filter orders by status | |
add_filter('woocommerce_my_account_my_orders_query', 'ts_my_account_orders_filter_by_status'); | |
function ts_my_account_orders_filter_by_status($args) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add Zirconia column to the Orders page in WooCommerce admin | |
function ts_add_zirconia_column($columns) { | |
$columns['zirconia'] = __('Zirconia', 'woocommerce'); | |
return $columns; | |
} | |
add_filter('manage_woocommerce_page_wc-orders_columns', 'ts_add_zirconia_column'); | |
// Display the Zirconia value in the Zirconia column | |
function ts_display_zirconia_column($column, $post_id) { | |
if ($column == 'zirconia') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add Zirconia column to the Orders page in WooCommerce admin | |
function ts_add_zirconia_column($columns) { | |
$columns['zirconia'] = __('Zirconia', 'woocommerce'); | |
return $columns; | |
} | |
add_filter('manage_woocommerce_page_wc-orders_columns', 'ts_add_zirconia_column'); | |
// Display the Zirconia value in the Zirconia column | |
function ts_display_zirconia_column($column, $post_id) { | |
if ($column == 'zirconia') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('woocommerce_after_add_to_cart_form', 'ts_dispatch_info_single_product'); | |
function ts_dispatch_info_single_product() { | |
// Get the current time according to WordPress timezone settings | |
$current_time = current_time('mysql'); | |
// Convert the current time to a DateTime object | |
$current_datetime = new DateTime($current_time); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'woocommerce_available_payment_gateways', 'ts_gateway_disable_for_shipping_rate' ); | |
function ts_gateway_disable_for_shipping_rate( $available_gateways ) { | |
if ( ! is_admin() && WC()->session ) { | |
$chosen_methods = WC()->session->get( 'chosen_shipping_methods' ); | |
$chosen_shipping = $chosen_methods[0]; | |
if ( isset( $available_gateways['cod'] ) && 0 === strpos( $chosen_shipping, 'local_pickup' ) ) { | |
unset( $available_gateways['cod'] ); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'wp_footer', 'ts_cart_refresh_update_qty' ); | |
function ts_cart_refresh_update_qty() { | |
if ( is_cart() || ( is_cart() && is_checkout() ) ) { | |
wc_enqueue_js( " | |
$('div.woocommerce').on('click', 'input.qty', function(){ | |
$('[name=\'update_cart\']').trigger('click'); | |
}); | |
" ); |