Skip to content

Instantly share code, notes, and snippets.

KoolPal

Block or report user

Report or block KoolPal

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@KoolPal
KoolPal / gist:ba0dce676b522fd8a202c70de0956ff6
Created Oct 1, 2019
Retain Quote Billing & Shipping Country ELSE assign Location based on IP (Geolocation)
View gist:ba0dce676b522fd8a202c70de0956ff6
// 06-05-2019 Retain Quote Billing & Shipping Country ELSE assign Location based on IP (Geolocation)
function remove_checkout_optional_fields_label_script() {
// Only on checkout page
if( ! ( is_checkout() && ! is_wc_endpoint_url() ) ) return;
$optional = '&nbsp;<span class="optional">(' . esc_html__( 'optional', 'woocommerce' ) . ')</span>';
?>
<script>
jQuery(function($){
// On "update" checkout form event remove option to select countries
$(document.body).on('update_checkout', function(){
@KoolPal
KoolPal / WooCommerce Auto update cart after quantity change.php Auto update cart after quantity change. You trigger the click, but the button doesn't have enough time to become enabled, so that is why, by the time you click the second time the button becomes enabled. Remove the "disabled" propriety before triggering the click. This should be added in **footer.php** of your child theme
View WooCommerce Auto update cart after quantity change.php
<?php if (is_cart()) { ?>
<script type="text/javascript">
// Each time quantity in the cart changes, trigger update
// cart option
jQuery('div.woocommerce').on('change', '.qty', function(){
// Make sure the button is enabled before triggering the event
// otherwise this won't work.
jQuery("[name='update_cart']").prop("disabled", false);
jQuery("[name='update_cart']").trigger("click");
});
@KoolPal
KoolPal / gist:136c70d495b4d85601f75bbcc562b3e4
Created Jun 9, 2017 — forked from corsonr/gist:c2781c9e0cc086c5047f
WooCommerce: Add customer username to edit/view order admin page
View gist:136c70d495b4d85601f75bbcc562b3e4
<?php
// Add WooCommerce customer username to edit/view order admin page
add_action( 'woocommerce_admin_order_data_after_billing_address', 'woo_display_order_username', 10, 1 );
function woo_display_order_username( $order ){
global $post;
$customer_user = get_post_meta( $post->ID, '_customer_user', true );
echo '<p><strong style="display: block;">'.__('Customer Username').':</strong> <a href="user-edit.php?user_id=' . $customer_user . '">' . get_user_meta( $customer_user, 'nickname', true ) . '</a></p>';
You can’t perform that action at this time.