Get get_zone_name() with ajax
-
Hi
I need to display a text where the title is on the shipping zone in which the customer fits.
I have made the code that shows the name of the shipping zone, but the title of the shipping zone does not change when the customer changes his zip code.
I have tried calling the php code using ajax but I have not been able to get it to work.
Anyone have a solution to this?
Script
<script> $(document).ready(function() { $("#billing_postcode").keypress(function() { $.get("postcode.php", function(data, status) { $("#test").html(data); }) }); }); </script>
postcode.php
<?php $shipping_packages = WC()->cart->get_shipping_packages(); // Get the WC_Shipping_Zones instance object for the first package $shipping_zone = wc_get_shipping_zone( reset( $shipping_packages ) ); $zone_name = $shipping_zone->get_zone_name(); // Get the zone name echo $zone_name;
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Get get_zone_name() with ajax’ is closed to new replies.