Add tool for disabling shipping rate cache for debug

This commit is contained in:
Mike Jolley 2014-05-01 14:40:28 +01:00
parent f3107b2ef6
commit 78e9aed6c1
2 changed files with 15 additions and 3 deletions

View File

@ -1,6 +1,6 @@
<form method="post" action="options.php"> <form method="post" action="options.php">
<?php settings_fields( 'woocommerce_status_settings_fields' ); ?> <?php settings_fields( 'woocommerce_status_settings_fields' ); ?>
<?php $options = wp_parse_args( get_option( 'woocommerce_status_options', array() ), array( 'uninstall_data' => 0, 'template_debug_mode' => 0 ) ); ?> <?php $options = wp_parse_args( get_option( 'woocommerce_status_options', array() ), array( 'uninstall_data' => 0, 'template_debug_mode' => 0, 'shipping_debug_mode' => 0 ) ); ?>
<table class="wc_status_table widefat" cellspacing="0"> <table class="wc_status_table widefat" cellspacing="0">
<thead class="tools"> <thead class="tools">
<tr> <tr>
@ -19,6 +19,17 @@
</td> </td>
</tr> </tr>
<?php } ?> <?php } ?>
<tr>
<td><?php _e( 'Shipping Debug Mode', 'woocommerce' ); ?></td>
<td>
<p>
<label><input type="checkbox" class="checkbox" name="woocommerce_status_options[shipping_debug_mode]" value="1" <?php checked( '1', $options['shipping_debug_mode'] ); ?> /> <?php _e( 'Enabled', 'woocommerce' ); ?></label>
</p>
<p>
<span class="description"><?php _e( 'This tool will disable shipping rate caching.', 'woocommerce' ); ?></span>
</p>
</td>
</tr>
<tr> <tr>
<td><?php _e( 'Template Debug Mode', 'woocommerce' ); ?></td> <td><?php _e( 'Template Debug Mode', 'woocommerce' ); ?></td>
<td> <td>

View File

@ -338,9 +338,10 @@ class WC_Shipping {
if ( ! $package ) return false; if ( ! $package ) return false;
// Check if we need to recalculate shipping for this package // Check if we need to recalculate shipping for this package
$package_hash = 'wc_ship_' . md5( json_encode( $package ) ); $package_hash = 'wc_ship_' . md5( json_encode( $package ) );
$status_options = get_option( 'woocommerce_status_options', array() );
if ( false === ( $stored_rates = get_transient( $package_hash ) ) ) { if ( false === ( $stored_rates = get_transient( $package_hash ) ) || ( ! empty( $status_options['shipping_debug_mode'] ) && current_user_can( 'manage_options' ) ) ) {
// Calculate shipping method rates // Calculate shipping method rates
$package['rates'] = array(); $package['rates'] = array();