Last active
April 11, 2016 18:33
-
-
Save claudiosanches/6092345 to your computer and use it in GitHub Desktop.
WooCommerce - Custom Shipping Calculator
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 | |
/** | |
* Shipping Calculator | |
* | |
* This template can be overridden by copying it to yourtheme/woocommerce/cart/shipping-calculator.php. | |
* | |
* HOWEVER, on occasion WooCommerce will need to update template files and you (the theme developer). | |
* will need to copy the new files to your theme to maintain compatibility. We try to do this. | |
* as little as possible, but it does happen. When this occurs the version of the template file will. | |
* be bumped and the readme will list any important changes. | |
* | |
* @see http://docs.woothemes.com/document/template-structure/ | |
* @author WooThemes | |
* @package WooCommerce/Templates | |
* @version 2.5.0 | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; | |
} | |
if ( 'no' === get_option( 'woocommerce_enable_shipping_calc' ) || ! WC()->cart->needs_shipping() ) { | |
return; | |
} | |
?> | |
<?php do_action( 'woocommerce_before_shipping_calculator' ); ?> | |
<form class="woocommerce-shipping-calculator" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post"> | |
<p><a href="#" class="shipping-calculator-button"><?php _e( 'Calculate Shipping', 'woocommerce' ); ?></a></p> | |
<section class="shipping-calculator-form" style="display: none;"> | |
<input type="hidden" name="calc_shipping_country" value="BR" /> | |
<input type="hidden" name="calc_shipping_state" value="SP" /> | |
<p class="form-row form-row-wide" id="calc_shipping_postcode_field"> | |
<input type="text" class="input-text" value="<?php echo esc_attr( WC()->customer->get_shipping_postcode() ); ?>" placeholder="<?php esc_attr_e( 'Postcode / ZIP', 'woocommerce' ); ?>" name="calc_shipping_postcode" id="calc_shipping_postcode" /> | |
</p> | |
<p><button type="submit" name="calc_shipping" value="1" class="button"><?php _e( 'Update Totals', 'woocommerce' ); ?></button></p> | |
<?php wp_nonce_field( 'woocommerce-cart' ); ?> | |
</section> | |
</form> | |
<?php do_action( 'woocommerce_after_shipping_calculator' ); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment