Skip to content

Instantly share code, notes, and snippets.

@rayflores
Created September 4, 2014 05:00
Show Gist options
  • Save rayflores/ec868f3efd55f7565ce0 to your computer and use it in GitHub Desktop.
Save rayflores/ec868f3efd55f7565ce0 to your computer and use it in GitHub Desktop.
<?php
/**
* Shipping Methods Display - cart-shipping.php template /woocommerce/cart/cart-shipping.php
*
* In 2.1 we show methods per package. This allows for multiple methods per order if so desired.
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.1.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
?>
<?php
foreach ( $package['contents'] as $item_id => $values ) {
if ( $values['data']->needs_shipping() ) {
$shipm = $values['data']->get_shipping_class();
//echo print_r( $shipm, true ); // make sure you are capturing classes by printing them to the screen here
}
}
?>
<tr class="shipping">
<th><?php
if ( $show_package_details ) {
$num_index = $index + 1;
if($shipm == 'class-1') {
_e( 'Class One Title', 'woocommerce' );
} elseif($shipm == 'class-2'){
_e( 'Class Two Title', 'woocommerce' );
//printf( __( 'Shipping #%d', 'woocommerce' ), $num_index );
} elseif($shipm == 'class-3'){
_e( 'Class Three Title', 'woocommerce' );
}elseif($shipm == 'free-shipping'){
_e( 'Free Shipping Class', 'woocommerce' );
}
} else {
_e( 'Shipping and Handling', 'woocommerce' );
}
?></th>
@DaveStjean
Copy link

Hello, I know this is old and I'm new to all this, but where would I implement this code into the cart-shipping.php?

@inspiredearth
Copy link

I would also be grateful to hear from you on how to implement this. I came here via https://wordpress.org/support/topic/shipping-titles/#post-4967609, and I am looking for a way to rename the split shipping packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment