?> " value="<?php echo esc_attr($method->id); ?> " <?php checked($method->id, $chosen_method); ?> class="shipping_method" /> <label for="shipping_method_<?php echo esc_attr($index); ?> _<?php echo sanitize_title($method->id); ?> "><?php echo wp_kses_post(wc_cart_totals_shipping_method_label($method)); ?> </label> </li> <?php } ?> </ul> <?php } ?> <?php } elseif (!WC()->customer->get_shipping_state() || !WC()->customer->get_shipping_postcode()) { ?>
<?php printf('<input type="radio" name="shipping_method[%1$d]" data-index="%1$d" id="shipping_method_%1$d_%2$s" value="%3$s" class="shipping_method" %4$s /> <label for="shipping_method_%1$d_%2$s">%5$s</label>', $index, sanitize_title($method->id), esc_attr($method->id), checked($method->id, $chosen_method, false), wc_cart_totals_shipping_method_label($method)); do_action('woocommerce_after_shipping_rate', $method, $index); ?> </li> <?php } ?> </ul> <?php } elseif (1 === count($available_methods)) { ?> <?php $method = current($available_methods); printf('%3$s <input type="hidden" name="shipping_method[%1$d]" data-index="%1$d" id="shipping_method_%1$d" value="%2$s" class="shipping_method" />', $index, esc_attr($method->id), wc_cart_totals_shipping_method_label($method)); do_action('woocommerce_after_shipping_rate', $method, $index); ?> <?php } elseif (!WC()->customer->has_calculated_shipping()) { ?> <?php echo wpautop(__('Shipping costs will be calculated once you have provided your address.', 'woocommerce')); ?> <?php } else { ?> <?php echo apply_filters(is_cart() ? 'woocommerce_cart_no_shipping_available_html' : 'woocommerce_no_shipping_available_html', wpautop(__('There are no shipping methods available. Please double check your address, or contact us if you need any help.', 'woocommerce'))); ?> <?php
/** * @deprecated */ function woocommerce_cart_totals_shipping_method_label($method) { return wc_cart_totals_shipping_method_label($method); }
<?php elseif ( get_option( 'woocommerce_shipping_method_format' ) === 'select' ) : ?> <select name="shipping_method[<?php echo $index; ?>]" data-index="<?php echo $index; ?>" id="shipping_method_<?php echo $index; ?>" class="shipping_method"> <?php foreach ( $available_methods as $method ) : ?> <option value="<?php echo esc_attr( $method->id ); ?>" <?php selected( $method->id, $chosen_method ); ?>><?php echo wp_kses_post( wc_cart_totals_shipping_method_label( $method ) ); ?></option> <?php endforeach; ?> </select> <?php else : ?> <ul id="shipping_method"> <?php foreach ( $available_methods as $method ) : ?> <li> <input type="radio" name="shipping_method[<?php echo $index; ?>]" data-index="<?php echo $index; ?>" id="shipping_method_<?php echo $index; ?>_<?php echo sanitize_title( $method->id ); ?>" value="<?php echo esc_attr( $method->id ); ?>" <?php checked( $method->id, $chosen_method ); ?> class="shipping_method" /> <label for="shipping_method_<?php echo $index; ?>_<?php echo sanitize_title( $method->id ); ?>"><?php echo wp_kses_post( wc_cart_totals_shipping_method_label( $method ) ); ?></label> </li> <?php endforeach; ?> </ul> <?php endif; ?> <?php elseif ( ! WC()->customer->get_shipping_state() || ! WC()->customer->get_shipping_postcode() ) : ?> <?php if ( is_cart() ) : ?> <p><?php echo $noshipping_found; ?></p> <?php else : ?> <p><?php echo $please_fill; ?></p>
?> " value="<?php echo esc_attr($method->id); ?> " <?php checked($method->id, $chosen_method); ?> class="shipping_method" /> <label for="shipping_method_<?php echo $index; ?> _<?php echo sanitize_title($method->id); ?> "><?php echo wp_kses_post(str_replace("Entrega em", "", wc_cart_totals_shipping_method_label($method))); ?> </label> </li> <?php } ?> </ul> <?php } ?> <?php } elseif (!WC()->customer->get_shipping_state() || !WC()->customer->get_shipping_postcode()) { ?>
?> " value="<?php echo esc_attr($method->id); ?> " <?php checked($method->id, $chosen_method); ?> class="shipping_method" /> <label for="shipping_method_<?php echo $index; ?> _<?php echo sanitize_title($method->id); ?> "><?php echo wc_cart_totals_shipping_method_label($method); ?> </label> </li> <?php } ?> </ul> <?php } ?> <?php if ($show_package_details) { ?>
/** * @param array $packages * @param int $type 0=multi-shipping; 1=different packages; 2=same packages */ function render_shipping_row($packages, $type = 2) { global $woocommerce; $page_id = woocommerce_get_page_id('multiple_addresses'); $_tax = new WC_Tax(); $rates_available = false; if (function_exists('wc_add_notice')) { $available_methods = $this->get_available_shipping_methods(); } else { $available_methods = $woocommerce->shipping->get_available_shipping_methods(); } $field_name = 'shipping_methods'; $post = array(); if (function_exists('wc_add_notice')) { $field_name = 'shipping_method'; } if (isset($_POST['post_data'])) { parse_str($_POST['post_data'], $post); } if ($type == 0 || $type == 1) { ?> <tr class="multi_shipping"> <td style="vertical-align: top;" colspan="<?php if (version_compare(WOOCOMMERCE_VERSION, '2.0', '<')) { echo '2'; } else { echo '1'; } ?> "> <?php _e('Shipping Methods', 'wc_shipping_multiple_address'); ?> <div id="shipping_addresses"> <?php $tips = array(); foreach ($packages as $x => $package) { $package = $woocommerce->shipping->calculate_shipping_for_package($package); $has_address = true; if (!isset($package['full_address']) || empty($package['full_address'])) { $has_address = false; } elseif ($this->is_address_empty($package['full_address'])) { $has_address = false; } elseif ($this->is_address_empty($package['destination'])) { $has_address = false; } elseif (!isset($package['rates']) || empty($package['rates'])) { $has_address = false; } if (!$has_address) { // we have cart items with no set address $products = $package['contents']; ?> <div class="ship_address no_shipping_address"> <em><?php _e('The following items do not have shipping addresses assigned.', 'wc_shipping_multiple_address'); ?> </em> <ul> <?php foreach ($products as $i => $product) { $attributes = $woocommerce->cart->get_item_data($product); ?> <li> <strong><?php echo get_the_title($product['data']->id); ?> x <?php echo $product['quantity']; ?> </strong> <?php if (!empty($attributes)) { echo '<small class="data">' . str_replace("\n", "<br/>", $attributes) . '</small>'; } ?> </li> <?php } ?> </ul> <?php $sess_cart_addresses = wcms_session_get('cart_item_addresses'); //if ( $sess_cart_addresses && !empty($sess_cart_addresses) ) { echo '<p style="text-align: center"><a href="' . get_permalink($page_id) . '" class="button modify-address-button">' . __('Assign Shipping Address', 'wc_shipping_multiple_address') . '</a></p>'; //} ?> </div> <?php continue; } $shipping_methods = array(); $products = $package['contents']; //$shipping_methods = $package['rates']; $selected = wcms_session_get('shipping_methods'); $rates_available = true; if ($type == 0) { ?> <div class="ship_address"> <dl> <?php foreach ($products as $i => $product) { $attributes = $woocommerce->cart->get_item_data($product, true); ?> <dd> <strong><?php echo get_the_title($product['data']->id); ?> x <?php echo $product['quantity']; ?> </strong> <?php if (!empty($attributes)) { echo '<small class="data">' . str_replace("\n", "<br/>", $attributes) . '</small>'; } ?> </dd> <?php } ?> </dl> <?php $formatted_address = wcms_get_formatted_address($package['full_address']); echo '<address>' . $formatted_address . '</address><br />'; ?> <?php do_action('wc_ms_shipping_package_block', $x, $package); // If at least one shipping method is available $ship_package['rates'] = array(); foreach ($package['rates'] as $rate) { $ship_package['rates'][$rate->id] = $rate; } foreach ($ship_package['rates'] as $method) { if ($method->id == 'multiple_shipping') { continue; } $method->label = esc_html($method->label); if ($method->cost > 0) { $shipping_tax = $method->get_shipping_tax(); $method->label .= ' — '; // Append price to label using the correct tax settings if ($woocommerce->cart->display_totals_ex_tax || !$woocommerce->cart->prices_include_tax) { if ($shipping_tax > 0) { if ($woocommerce->cart->prices_include_tax) { $method->label .= woocommerce_price($method->cost) . ' ' . $woocommerce->countries->ex_tax_or_vat(); } else { $method->label .= woocommerce_price($method->cost); } } else { $method->label .= woocommerce_price($method->cost); } } else { $method->label .= woocommerce_price($method->cost + $shipping_tax); if ($shipping_tax > 0 && !$woocommerce->cart->prices_include_tax) { $method->label .= ' ' . $woocommerce->countries->inc_tax_or_vat(); } } } $shipping_methods[] = $method; } // Print the single available shipping method as plain text if (1 === count($shipping_methods)) { $method = $shipping_methods[0]; echo $method->label; echo '<input type="hidden" class="shipping_methods shipping_method" name="' . $field_name . '[' . $x . ']" value="' . esc_attr($method->id) . '">'; // Show multiple shipping methods in a select list } elseif (count($shipping_methods) > 1) { echo '<select class="shipping_methods shipping_method" name="' . $field_name . '[' . $x . ']">'; foreach ($package['rates'] as $rate) { if ($rate->id == 'multiple_shipping') { continue; } $sel = ''; if (isset($selected[$x]) && $selected[$x]['id'] == $rate->id) { $sel = 'selected'; } echo '<option value="' . esc_attr($rate->id) . '" ' . $sel . '>'; echo strip_tags($rate->label); echo '</option>'; } echo '</select>'; } else { echo '<p>' . __('(1) Sorry, it seems that there are no available shipping methods for your state. Please contact us if you require assistance or wish to make alternate arrangements.', 'woocommerce') . '</p>'; } $sess_cart_addresses = wcms_session_get('cart_item_addresses'); if ($sess_cart_addresses && !empty($sess_cart_addresses)) { echo '<p><a href="' . get_permalink($page_id) . '" class="modify-address-button">' . __('Modify address', 'wc_shipping_multiple_address') . '</a></p>'; } ?> </div> <?php } elseif ($type == 1) { ?> <div class="ship_address"> <dl> <?php foreach ($products as $i => $product) { $attributes = $woocommerce->cart->get_item_data($product); ?> <dd> <strong><?php echo get_the_title($product['data']->id); ?> x <?php echo $product['quantity']; ?> </strong> <?php if (!empty($attributes)) { echo '<small class="data">' . str_replace("\n", "<br/>", $attributes) . '</small>'; } ?> </dd> <?php } ?> </dl> <?php // If at least one shipping method is available // Calculate shipping method rates $ship_package['rates'] = array(); foreach ($woocommerce->shipping->load_shipping_methods($package) as $shipping_method) { if (isset($package['method']) && !in_array($shipping_method->id, $package['method'])) { continue; } if ($shipping_method->is_available($package)) { // Reset Rates $shipping_method->rates = array(); // Calculate Shipping for package $shipping_method->calculate_shipping($package); // Place rates in package array if (!empty($shipping_method->rates) && is_array($shipping_method->rates)) { foreach ($shipping_method->rates as $rate) { $ship_package['rates'][$rate->id] = $rate; } } } } foreach ($ship_package['rates'] as $method) { if ($method->id == 'multiple_shipping') { continue; } $method->label = esc_html($method->label); if ($method->cost > 0) { $shipping_tax = $method->get_shipping_tax(); $method->label .= ' — '; // Append price to label using the correct tax settings if ($woocommerce->cart->display_totals_ex_tax || !$woocommerce->cart->prices_include_tax) { if ($shipping_tax > 0) { if ($woocommerce->cart->prices_include_tax) { $method->label .= woocommerce_price($method->cost) . ' ' . $woocommerce->countries->ex_tax_or_vat(); } else { $method->label .= woocommerce_price($method->cost); } } else { $method->label .= woocommerce_price($method->cost); } } else { $method->label .= woocommerce_price($method->cost + $shipping_tax); if ($shipping_tax > 0 && !$woocommerce->cart->prices_include_tax) { $method->label .= ' ' . $woocommerce->countries->inc_tax_or_vat(); } } } $shipping_methods[] = $method; } // Print a single available shipping method as plain text if (1 === count($shipping_methods)) { $method = $shipping_methods[0]; echo $method->label; echo '<input type="hidden" class="shipping_methods shipping_method" name="' . $field_name . '[' . $x . ']" value="' . esc_attr($method->id) . '||' . strip_tags($method->label) . '">'; // Show multiple shipping methods in a select list } elseif (count($shipping_methods) > 1) { echo '<select class="shipping_methods shipping_method" name="' . $field_name . '[' . $x . ']">'; foreach ($shipping_methods as $method) { if ($method->id == 'multiple_shipping') { continue; } $current_selected = isset($selected[$x]) ? $selected[$x]['id'] : ''; echo '<option value="' . esc_attr($method->id) . '||' . strip_tags($method->label) . '" ' . selected($current_selected, $method->id, false) . '>'; if (function_exists('wc_cart_totals_shipping_method_label')) { echo wp_kses_post(wc_cart_totals_shipping_method_label($method)); } else { echo strip_tags($method->label); } echo '</option>'; } echo '</select>'; } else { echo '<p>' . __('(2) Sorry, it seems that there are no available shipping methods for your state. Please contact us if you require assistance or wish to make alternate arrangements.', 'woocommerce') . '</p>'; } $sess_cart_addresses = wcms_session_get('cart_item_addresses'); if ($sess_cart_addresses && !empty($sess_cart_addresses)) { echo '<p><a href="' . get_permalink($page_id) . '" class="modify-address-button">' . __('Modify address', 'wc_shipping_multiple_address') . '</a></p>'; } ?> </div> <?php } } ?> <div style="clear:both;"></div> <?php if (!function_exists('wc_add_notice')) { ?> <input type="hidden" name="shipping_method" value="multiple_shipping" /> <?php } ?> </div> </td> <td style="vertical-align: top;"> <?php $shipping_total = $woocommerce->cart->shipping_total; $shipping_tax = $woocommerce->cart->shipping_tax_total; $inc_or_exc_tax = ''; if ($shipping_total > 0) { // Append price to label using the correct tax settings if ($woocommerce->cart->display_totals_ex_tax || !$woocommerce->cart->prices_include_tax) { if ($shipping_tax > 0) { if ($woocommerce->cart->prices_include_tax) { $shipping_total = $shipping_total; $inc_or_exc_tax = $woocommerce->countries->ex_tax_or_vat(); } else { $shipping_total += $shipping_tax; $inc_or_exc_tax = $woocommerce->countries->inc_tax_or_vat(); } } } else { $shipping_total += $shipping_tax; if ($shipping_tax > 0 && !$woocommerce->cart->prices_include_tax) { $inc_or_exc_tax = $woocommerce->countries->inc_tax_or_vat(); } } } echo woocommerce_price($shipping_total) . ' ' . $inc_or_exc_tax; ?> </td> <script type="text/javascript"> jQuery(document).ready(function() { jQuery("tr.shipping").remove(); }); <?php if (null == wcms_session_get('shipping_methods') && $rates_available) { echo 'jQuery("body").trigger("update_checkout");'; } ?> </script> </tr> <?php } else { ?> <tr class="multi_shipping"> <td style="vertical-align: top;" colspan="<?php if (version_compare(WOOCOMMERCE_VERSION, '2.0', '<')) { echo '2'; } else { echo '1'; } ?> "> <?php _e('Shipping Methods', 'wc_shipping_multiple_address'); ?> <?php $tips = array(); foreach ($packages as $x => $package) { $shipping_methods = array(); $products = $package['contents']; if ($type == 2) { // If at least one shipping method is available // Calculate shipping method rates $ship_package['rates'] = array(); foreach ($woocommerce->shipping->load_shipping_methods($package) as $shipping_method) { if (isset($package['method']) && !in_array($shipping_method->id, $package['method'])) { continue; } if ($shipping_method->is_available($package)) { // Reset Rates $shipping_method->rates = array(); // Calculate Shipping for package $shipping_method->calculate_shipping($package); // Place rates in package array if (!empty($shipping_method->rates) && is_array($shipping_method->rates)) { foreach ($shipping_method->rates as $rate) { $ship_package['rates'][$rate->id] = $rate; } } } } foreach ($ship_package['rates'] as $method) { if ($method->id == 'multiple_shipping') { continue; } $method->label = esc_html($method->label); if ($method->cost > 0) { $method->label .= ' — '; // Append price to label using the correct tax settings if ($woocommerce->cart->display_totals_ex_tax || !$woocommerce->cart->prices_include_tax) { $method->label .= woocommerce_price($method->cost); if ($method->get_shipping_tax() > 0 && $woocommerce->cart->prices_include_tax) { $method->label .= ' ' . $woocommerce->countries->ex_tax_or_vat(); } } else { $method->label .= woocommerce_price($method->cost + $method->get_shipping_tax()); if ($method->get_shipping_tax() > 0 && !$woocommerce->cart->prices_include_tax) { $method->label .= ' ' . $woocommerce->countries->inc_tax_or_vat(); } } } $shipping_methods[] = $method; } // Print a single available shipping method as plain text if (1 === count($shipping_methods)) { $method = $shipping_methods[0]; echo $method->label; echo '<input type="hidden" class="shipping_methods shipping_method" name="' . $field_name . '[' . $x . ']" value="' . esc_attr($method->id) . '">'; // Show multiple shipping methods in a select list } elseif (count($shipping_methods) > 1) { echo '<select class="shipping_methods shipping_method" name="' . $field_name . '[' . $x . ']">'; foreach ($shipping_methods as $method) { if ($method->id == 'multiple_shipping') { continue; } echo '<option value="' . esc_attr($method->id) . '" ' . selected($method->id, isset($post['shipping_method']) ? $post['shipping_method'] : '', false) . '>'; echo strip_tags($method->label); echo '</option>'; } echo '</select>'; } else { echo '<p>' . __('(3) Sorry, it seems that there are no available shipping methods for your state. Please contact us if you require assistance or wish to make alternate arrangements.', 'woocommerce') . '</p>'; } $sess_cart_addresses = wcms_session_get('cart_item_addresses'); if ($sess_cart_addresses && !empty($sess_cart_addresses)) { echo '<p><a href="' . get_permalink($page_id) . '" class="modify-address-button">' . __('Modify address', 'wc_shipping_multiple_address') . '</a></p>'; } } } ?> </td> <td style="vertical-align: top;"><?php echo woocommerce_price($woocommerce->cart->shipping_total + $woocommerce->cart->shipping_tax_total); ?> </td> <script type="text/javascript"> jQuery("tr.shipping").remove(); <?php if (null == wcms_session_get('shipping_methods') && $rates_available) { echo 'jQuery("body").trigger("update_checkout");'; } ?> </script> </tr> <?php } }
/** * * * /** * Gets shipping options as formatted HTML. * * @since 2.0 **/ function klarna_checkout_get_shipping_options_row_html() { global $woocommerce; ob_start(); if (!defined('WOOCOMMERCE_CART')) { define('WOOCOMMERCE_CART', true); } $woocommerce->cart->calculate_shipping(); $woocommerce->cart->calculate_fees(); $woocommerce->cart->calculate_totals(); ?> <tr id="kco-page-shipping"> <?php // if ( WC()->session->get( 'klarna_is_rest', false ) ) { // Just show shipping cost for Rest // Temporarily commented out while Klarna works on this feaure and replaced by the check below // that always returns true. ?> <?php if (1 > 2) { // Just show shipping cost for Rest ?> <td class="kco-rightalign"> <?php _e('Shipping', 'woocommerce-gateway-klarna'); ?> </td> <td id="kco-page-shipping-total"> <?php echo $woocommerce->cart->get_cart_shipping_total(); ?> </td> <?php } else { ?> <td> <?php $woocommerce->cart->calculate_shipping(); $packages = $woocommerce->shipping->get_packages(); foreach ($packages as $i => $package) { $chosen_method = isset($woocommerce->session->chosen_shipping_methods[$i]) ? $woocommerce->session->chosen_shipping_methods[$i] : ''; $available_methods = $package['rates']; $show_package_details = sizeof($packages) > 1; $index = $i; ?> <?php if (!empty($available_methods)) { ?> <?php if (1 === count($available_methods)) { $method = current($available_methods); echo wp_kses_post(wc_cart_totals_shipping_method_label($method)); ?> <input type="hidden" name="shipping_method[<?php echo esc_attr($index); ?> ]" data-index="<?php echo esc_attr($index); ?> " id="shipping_method_<?php echo esc_attr($index); ?> " value="<?php echo esc_attr($method->id); ?> " class="shipping_method"/> <?php } else { ?> <p style="margin: 0 0 0.5em !important; padding: 0 !important;"><?php _e('Shipping', 'woocommerce-gateway-klarna'); ?> </p> <ul id="shipping_method"> <?php foreach ($available_methods as $method) { ?> <li> <input style="margin-left:3px" type="radio" name="shipping_method[<?php echo esc_attr($index); ?> ]" data-index="<?php echo esc_attr($index); ?> " id="shipping_method_<?php echo esc_attr($index); ?> _<?php echo esc_attr(sanitize_title($method->id)); ?> " value="<?php echo esc_attr($method->id); ?> " <?php checked($method->id, $chosen_method); ?> class="shipping_method"/> <label for="shipping_method_<?php echo esc_attr($index); ?> _<?php echo esc_attr(sanitize_title($method->id)); ?> "><?php echo wp_kses_post(wc_cart_totals_shipping_method_label($method)); ?> </label> </li> <?php } ?> </ul> <?php } ?> <?php } ?> <?php } ?> </td> <td id="kco-page-shipping-total" class="kco-rightalign"> <?php echo $woocommerce->cart->get_cart_shipping_total(); ?> </td> <?php } ?> </tr> <?php return ob_get_clean(); }
/** * @param array $data */ function hwoo_shipping_method_list() { $data = utility_data(func_get_args()); $index = $data['index']; $chosen_method = $data['chosen_method']; foreach ($data['available_methods'] as $method) { ?> <li> <input type="radio" name="shipping_method[<?php echo $index; ?> ]" data-index="<?php echo $index; ?> " id="shipping_method_<?php echo $index; ?> _<?php echo sanitize_title($method->id); ?> " value="<?php echo esc_attr($method->id); ?> " <?php checked($method->id, $chosen_method); ?> class="shipping_method" /> <label for="shipping_method_<?php echo $index; ?> _<?php echo sanitize_title($method->id); ?> "><?php echo wp_kses_post(wc_cart_totals_shipping_method_label($method)); ?> </label> </li> <?php } }