I am using the below code to display price next to the variations in WooCommerce. It works great if more than 2 variations but if only 2 variations it displays only the first variations price for both variations.
Any help with this would be great.
function display_price_in_variation_option_name( $term ) {
global $wpdb, $product;
if ( is_product() ) {
if ( $product instanceof WC_Product && $product->is_type( 'variable' ) ) {
foreach ( $product->get_available_variations() as $variation ) {
//$product_variation_id = $variation['variation_id'];
foreach ( $variation['attributes'] as $variation_attribute_name => $variation_attribute_value ) {
$result = $wpdb->get_col( "SELECT slug FROM {$wpdb->prefix}terms WHERE slug = '$variation_attribute_value'" );
if ( $term != $variation_attribute_value && $variation_attribute_value != $result[0] ) continue;
$product_price = wc_price( $variation['display_price'] );
$product_price = strip_tags( $product_price );
return $term . ' - (' . $product_price . ')';
}
}
}
}
return $term;
}
add_filter( 'woocommerce_variation_option_name', 'display_price_in_variation_option_name' );
This code is tested and works with multiple dropdowns and multiple attributes and product specific attributes like, attribute1 | attribute2 | attribute3.
// Add the prices next to the variations in WooCommerce
add_filter( 'woocommerce_variation_option_name', 'display_price_in_variation_option_names' );
function display_price_in_variation_option_names( $term_name ) {
global $wpdb, $product;
if ( is_product() && $product instanceof WC_Product && $product->is_type( 'variable' ) ) {
foreach ( $product->get_available_variations() as $variation ) {
foreach ( $variation['attributes'] as $variation_attribute_name => $variation_attribute_value ) {
$result = $wpdb->get_col( "SELECT slug FROM {$wpdb->prefix}terms WHERE slug = '$variation_attribute_value'" );
$taxonomy = str_replace( 'attribute_', '', $variation_attribute_name );
$term = get_term_by( 'slug', $variation_attribute_value, $taxonomy );
if ( $term_name == $variation_attribute_value ) {
$product_price = wc_price( $variation['display_price'] );
$product_price = strip_tags( $product_price );
return $term_name . ' - (' . $product_price . ')';
} else if( is_object($term) && $term->name == $term_name ) {
$product_price = wc_price( $variation['display_price'] );
$product_price = strip_tags( $product_price );
return $term_name . ' - (' . $product_price . ')';
}
}
}
}
return $term_name;
}
Related
my wordpress template does not display the title attribute of the menu (but if I change the template it is okay), how could i solve it? the website in www.imsdesign.eu
I am assuming that you added title attributes to you menu by doing below steps:
From your WordPress dashboard, go to your Menus page (Appearance > Menus)
Select the Menu that you want to edit from the list of your Menus.
Click on the configuration arrow on the right side of the Menu Item title, that when clicked opens the configuration box.
Click on the “Screen Options” on top of the page to reveal additional advanced menu properties.
Activate the option for Title Attribute by selecting the Title Attribute box to expose the settings box under the Menu item instantly.
Add your Title Attribute in the text box just below the Navigation label option.
If it is still not working that's mean that you WP theme does not has title attributes. To change it please find the correct WP template (probably header.php) and add title attributes to nav elements by using method the_title_attribute()
<?php
class FastwpAltiusMenu {
private static $nav_template = '';
private static $nav_overlay = '';
function __construct() {
global $fastwp_altius_data, $fastwp_altius_menu_type;
$templates = array();
$templates[1] = array( 'nav' => 'fastwp-menu-default', 'overlay' => '' );
$templates[2] = array( 'nav' => 'fastwp-menu-overlay', 'overlay' => 'fastwp-menu-overlay2' );
if( is_page() ) {
$fastwp_altius_meta_type = get_post_meta( get_the_ID(), 'p_nav_style', true );
if( $fastwp_altius_meta_type == 1 || $fastwp_altius_meta_type == 2 ) {
$fastwp_altius_data['nav_style'] = $fastwp_altius_meta_type;
}
}
$menu = !empty( $fastwp_altius_data['nav_style'] ) && in_array( (int) $fastwp_altius_data['nav_style'], array_keys( $templates ) ) ? (int) $fastwp_altius_data['nav_style'] : 1;
$fastwp_altius_menu_type= $menu;
self::$nav_template = $templates[$menu]['nav'];
self::$nav_overlay = $templates[$menu]['overlay'];
}
public static function nav( $echo = true ) {
if( (boolean) $echo ) {
echo get_template_part( 'fastwp/menu/' . self::$nav_template );
}
ob_start();
get_template_part( 'fastwp/menu/' . self::$nav_template );
$content = ob_get_contents();
ob_end_clean();
return $content;
}
public static function overlay( $echo = true ) {
$nav_overlay = self::$nav_overlay;
if( !empty( $nav_overlay ) ) {
if( (boolean) $echo ) {
echo get_template_part( 'fastwp/menu/' . $nav_overlay );
}
ob_start();
get_template_part( 'fastwp/menu/' . $nav_overlay );
$content = ob_get_contents();
ob_end_clean();
return $content;
}
}
}
class FastwpAltiusWalker {
var $one_page = false;
function __construct( $menu_id, $menu = 0 ) {
$this->override_menu = $menu;
$elements = $this->nice_elements( $menu_id );
$this->main_elements = isset( $elements['main'] ) ? $elements['main'] : array();
$this->subnav_elements = isset( $elements['subnav'] ) ? $elements['subnav'] : array();
}
function set_onePage() {
$this->one_page = true;
}
function add_one_page_section( $item ) {
if( $this->one_page ) {
global $fastwp_altius_one_page_sections;
if( $item->object == 'page' ) {
if( empty( $fastwp_altius_one_page_sections ) ) $fastwp_altius_one_page_sections = array();
$section_name = preg_replace( '/[^a-z0-9_]/i', '', str_replace( ' ', '_', $item->title ) );
if( in_array( $section_name, array_keys( $fastwp_altius_one_page_sections ) ) ) {
$section_name = $section_name . '_' . $item->ID;
}
$fastwp_altius_one_page_sections[$section_name] = $item->object_id;
return '#section-' . $section_name;
}
}
return $item->url;
}
function get_menu() {
$output = '';
if( !empty( $this->main_elements ) ) {
/* Add Visual Composer meta */
global $fastwp_altius_one_page_css_vc;
$fastwp_altius_one_page_css_vc = array();
foreach( $this->main_elements as $item ) {
$item = $item[0];
$typeparent = get_post_meta( $item->ID, '_menu_item_menutype', true );
/* Add Visual Composer meta */
if( isset( $item->object_id ) ) {
$fastwp_altius_one_page_css_vc[$item->object_id] = get_post_meta( $item->object_id, '_wpb_shortcodes_custom_css', true );
}
$a_classes = $li_classes = $a_atts = $li_atts = array();
if( get_the_ID() == $item->object_id ) {
$li_classes[] = 'current';
}
if( isset( $item->hasChildren ) && $item->hasChildren ) {
$a_classes[] = 'sf-with-ul';
}
if( isset( $this->subnav_elements[$item->ID] ) ) {
$li_classes[] = 'parentMenuItem';
}
if( !empty( $item->classes ) ) {
$a_classes[] = implode( ' ', $item->classes );
}
$childrens = '';
if( $typeparent == 'mega2' ) {
$li_classes[] = 'dropDown megaMenu';
$items_array = $this->levels_recursive_array( $item->ID );
unset( $items_array['subnav'] );
$items_per_col = ceil( count( $items_array ) / 2 );
$col1_items = $col2_items = '';
foreach( $items_array as $k => $mitem ) {
$typechild = get_post_meta( $mitem->ID, '_menu_item_menutype2', true );
if( $k >= $items_per_col ) {
$col2_items .= $this->link_type( $mitem, $typechild );
} else {
$col1_items .= $this->link_type( $mitem, $typechild );
}
}
$childrens = '<div class="megaMenuContent cols2 clearfix">';
$childrens .= '<ul>' . $col1_items . '</ul>';
$childrens .= '<ul>' . $col2_items . '</ul>';
$childrens .= '</div>';
} else if( $typeparent == 'mega3' ) {
$li_classes[] = 'dropDown megaMenu';
$items_array = $this->levels_recursive_array( $item->ID );
unset( $items_array['subnav'] );
$items_per_col = ceil( count( $items_array ) / 3 );
$col1_items = $col2_items = $col3_items = '';
foreach( $items_array as $k => $mitem ) {
$typechild = get_post_meta( $mitem->ID, '_menu_item_menutype2', true );
if( $k < $items_per_col ) {
$col1_items .= $this->link_type( $mitem, $typechild );
} else if( $k/2 >= $items_per_col ) {
$col3_items .= $this->link_type( $mitem, $typechild );
} else {
$col2_items .= $this->link_type( $mitem, $typechild );
}
}
$childrens = '<div class="megaMenuContent cols3 clearfix">';
$childrens .= '<ul>' . $col1_items . '</ul>';
$childrens .= '<ul>' . $col2_items . '</ul>';
$childrens .= '<ul>' . $col3_items . '</ul>';
$childrens .= '</div>';
} else {
$childrens = $this->levels_recursive( $item->ID );
}
$output .= sprintf( "\n" . '<li%s%s><a href="%s"%s%s>%s</a>%s</li>',
( !empty( $li_classes ) ? ' class="' . implode( $li_classes, ' ' ) . '"' : '' ),
( !empty( $li_atts ) ? ' ' . implode( ' ', $li_atts ) : '' ),
$this->add_one_page_section( $item ),
( !empty( $a_classes ) ? ' class="' . implode( $a_classes, ' ' ) . '"' : ' ' ),
( !empty( $a_atts ) ? ' ' . implode( ' ', $a_atts ) : '' ),
$item->title,
$childrens );
}
}
return $output;
}
function link_type( $item = '', $type = '' ) {
$li_classes = array();
if( get_the_ID() == $item->object_id ) {
$li_classes[] = 'current';
}
if( $type == 'title' ) {
return '<li class="megaMenuTitle' . ( !empty( $li_classes ) ? ' ' . implode( ' ', $li_classes ) : '' ) . '">' . $item->title . '</li>';
} else {
return '<li' . ( !empty( $li_classes ) ? ' class="' . implode( ' ', $li_classes ) . '"' : '' ) . '>' . $item->title . '</li>';
}
}
function levels_recursive( $parent = 0, $level = 1 ) {
if( empty( $parent ) ) return ;
$output = '';
if( isset( $this->subnav_elements[$parent] ) ) {
$output .= '<ul class="fastwp-menu-level-' . $level . '">';
foreach( $this->subnav_elements[$parent] as $item ) {
$output .= '<li' . ( $this->item_has_children( $item->ID ) ? ' class="dropDown"' : '' ) . '>' . $item->title . '';
$output .= $this->levels_recursive( $item->ID, ($level+1) );
$output .= '</li>';
}
$output .= '</ul>';
}
return $output;
}
function item_has_children( $item = '' ) {
if( in_array( $item, array_keys( $this->subnav_elements ) ) ) {
return true;
}
return false;
}
function levels_recursive_array( $parent = 0 ) {
if( empty( $parent ) ) return array();
$output = array();
if( isset( $this->subnav_elements[$parent] ) ) {
foreach( $this->subnav_elements[$parent] as $item ) {
$output[] = $item;
$output['subnav'] = $this->levels_recursive( $item->ID );
}
}
return $output;
}
function nice_elements( $menu_id ) {
$elements = array();
foreach( $this->get_elements( $menu_id ) as $element ) {
if( !empty( $element->menu_item_parent ) ) {
$elements['subnav'][$element->menu_item_parent][] = $element;
} else {
$elements['main'][$element->ID][] = $element;
}
}
return $elements;
}
function get_elements( $menu_id = 'primary' ) {
$locations = get_nav_menu_locations();
if( !empty( $this->override_menu ) ) {
$menu = $this->override_menu;
} else {
$menu = $locations[$menu_id];
}
$elems = wp_get_nav_menu_items( get_term( $menu, 'nav_menu' ), array( 'depth' => 1 ) );
$return_elems = array();
foreach( $elems as $elem ) {
$return_elems[] = $elem;
}
return $return_elems;
}
}
How Can I change the Total price of the cart using hook.
I have tried many hooks without result.
i'm probably arrived to find the result .
This is what I have tried.
add_action('woocommerce_checkout_process', 'wh_getCartItemBeforePayment', 10);
function wh_getCartItemBeforePayment(){
if($_POST['percent']){
if($_POST['percent']==1){
/*WC()->cart->total*0.25;
WC()->cart->calculate_totals();
woocommerce_cart_totals();*/
/*
add_action('woocommerce_cart_calculate_fees','woocommerce_custom_surcharge' );
function woocommerce_custom_surcharge() {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
$percentage = 0.01;
$surcharge = ( $woocommerce->cart->cart_contents_total + $woocommerce->cart->shipping_total ) * $percentage;
$woocommerce->cart->add_fee( 'Surcharge', $surcharge, true, '' );
}
throw new Exception( __( WC()->cart->total ) );*/
//$items = WC()->cart->get_cart();
$cupom_value=-1;
foreach ($items as $item => $values)
{
$_product = $values['data']->post;
$product_title = $_product->post_title;
$qty = $values['quantity'];
$price = get_post_meta($values['product_id'], '_price', true);
$post_id = $value['product_id'];
$regular_price = get_post_meta( $post_id, '_regular_price', true);
$sale_price = get_post_meta( $post_id, '_sale_price', true);
$cupom_value = ($regular_price - $sale_price) *0.25;
$price = $cupom_value;
$value['data']->price = $price;
}
//$price=3*0.25;
wc_add_notice($cupom_value, 'error' );
}}}
add_action( 'woocommerce_calculate_totals', 'action_cart_calculate_totals', 10, 1 );
function action_cart_calculate_totals( $cart_object ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
if ( !WC()->cart->is_empty() ):
$cart_object->cart_contents_total += 10; // add 10 to cart total
endif;
}
I am writing a business extension (pdf printing) for the smart coupons.
Now I need a relation from the generated coupon (of the order) and the order item.
For example, which order item has generated the coupon?
Is there a way to get the order item_id from the coupon?
Is use this code to get the coupons:
$coupons = get_post_meta($order_id, 'sc_coupon_receiver_details', true));
Thank you very much
I have found a solution, but i had to put the code inside "woocommerce-smart-coupons.php" file.
Line 379: Extend the Filter Variables
add_filter( 'generate_smart_coupon_action', array( $this, 'generate_smart_coupon_action' ), 1, 10 );
Line 4783: Extend the Variable with the $item_id
if( $this->is_coupon_amount_pick_from_product_price( array( $coupon_title ) ) ) {
$email_to_credit[$receivers_emails[$coupon->id][0]][] = $coupon->id . ':' . $sc_called_credit_details[$item_id] . ':' . $item_id;
} else {
$email_to_credit[$receivers_emails[$coupon->id][0]][] = $coupon->id . ':' . $coupon->amount . ':' . $item_id;
}
Line 4816: Get the $item_id from the details and refer it to the "generate_smart_coupon" method
foreach ( $email_to_credit[$email_id] as $coupon_credit => $qty ) {
$coupon_details = explode( ':', $coupon_credit );
$coupon_title = get_the_title( $coupon_details[0] );
$coupon = new WC_Coupon( $coupon_title );
$credit_amount = $coupon_details[1];
$item_id = $coupon_details[2];
$message_index = array_search( $email_id, $email[$coupon->id], true );
if ( $message_index !== false && isset( $receivers_messages[$coupon->id][$message_index] ) && !empty( $receivers_messages[$coupon->id][$message_index] ) ) {
$message_from_sender = $receivers_messages[$coupon->id][$message_index];
} else {
$message_from_sender = '';
}
for ( $i = 0; $i < $qty; $i++ ) {
if ( $coupon->type != 'smart_coupon' ) continue; // only process smart_coupon here, rest coupon will be processed by function update_coupon
$this->generate_smart_coupon( $email_id, $credit_amount, $order_id, $coupon, 'smart_coupon', $gift_certificate_receiver_name, $message_from_sender, $gift_certificate_sender_name, $gift_certificate_sender_email, $item_id );
$smart_coupon_codes = array();
}
}
Line 5194: Change the Method and extend the variables
public function generate_smart_coupon( $email, $amount, $order_id = '', $coupon = '', $discount_type = 'smart_coupon', $gift_certificate_receiver_name = '', $message_from_sender = '', $gift_certificate_sender_name = '', $gift_certificate_sender_email = '', $item_id = '' ) {
return apply_filters( 'generate_smart_coupon_action', $email, $amount, $order_id, $coupon, $discount_type, $gift_certificate_receiver_name, $message_from_sender, $gift_certificate_sender_name, $gift_certificate_sender_email, $item_id );
}
Line 5212: Extend the filter method to
public function generate_smart_coupon_action( $email, $amount, $order_id = '', $coupon = '', $discount_type = 'smart_coupon', $gift_certificate_receiver_name = '', $message_from_sender = '', $gift_certificate_sender_name = '', $gift_certificate_sender_email = '', $item_id = '' ) {
Line 5307: Store the $item_id in the post_meta
update_post_meta( $smart_coupon_id, 'apply_before_tax', $apply_before_tax );
update_post_meta( $smart_coupon_id, 'free_shipping', $free_shipping );
update_post_meta( $smart_coupon_id, 'product_categories', $product_categories );
update_post_meta( $smart_coupon_id, 'exclude_product_categories', $exclude_product_categories );
update_post_meta( $smart_coupon_id, 'generated_from_order_id', $order_id );
update_post_meta( $smart_coupon_id, 'generated_from_item_id', $item_id );
i want to ask how to overwrite this woocommerce function (wp_schedule_single_event and post_status) using filter/action
Plugin file location : /woocommerce/includes/wc-order-functions.php
Original File :
/**
* Cancel all unpaid orders after held duration to prevent stock lock for those products.
*
* #access public
*/
function wc_cancel_unpaid_orders() {
global $wpdb;
$held_duration = get_option( 'woocommerce_hold_stock_minutes' );
if ( $held_duration < 1 || get_option( 'woocommerce_manage_stock' ) != 'yes' )
return;
$date = date( "Y-m-d H:i:s", strtotime( '-' . absint( $held_duration ) . ' MINUTES', current_time( 'timestamp' ) ) );
$unpaid_orders = $wpdb->get_col( $wpdb->prepare( "
SELECT posts.ID
FROM {$wpdb->posts} AS posts
WHERE posts.post_type IN ('" . implode( "','", wc_get_order_types() ) . "')
AND posts.post_status = 'wc-pending'
AND posts.post_modified < %s
", $date ) );
if ( $unpaid_orders ) {
foreach ( $unpaid_orders as $unpaid_order ) {
$order = wc_get_order( $unpaid_order );
if ( apply_filters( 'woocommerce_cancel_unpaid_order', 'checkout' === get_post_meta( $unpaid_order, '_created_via', true ), $order ) ) {
$order->update_status( 'cancelled', __( 'Unpaid order cancelled - time limit reached.', 'woocommerce' ) );
}
}
}
wp_clear_scheduled_hook( 'woocommerce_cancel_unpaid_orders' );
wp_schedule_single_event( time() + ( absint( $held_duration ) * 60 ), 'woocommerce_cancel_unpaid_orders' );
}
add_action( 'woocommerce_cancel_unpaid_orders', 'wc_cancel_unpaid_orders' );
I want to change this variable :
$unpaid_orders = $wpdb->get_col( $wpdb->prepare( "
SELECT posts.ID
FROM {$wpdb->posts} AS posts
WHERE posts.post_type IN ('" . implode( "','", wc_get_order_types() ) . "')
AND posts.post_status = '**wc-on-hold**'
AND posts.post_modified < %s
", $date ) );
and this
**wp_schedule_single_event( time() + 3600 ),** 'woocommerce_cancel_unpaid_orders' );
please help..
Thanks
Azreal
This is absolutely possible - wc_cancel_unpaid_orders is not called directly, rather it's hooked on to the woocommerce_cancel_unpaid_orders action, at line 488 of that file:
add_action( 'woocommerce_cancel_unpaid_orders', 'wc_cancel_unpaid_orders' );
this means that you can unhook THEIR wc_cancel_unpaid_orders, and assign your own. For example, you could add this to your functions.php file:
<?php
remove_action( 'woocommerce_cancel_unpaid_orders', 'wc_cancel_unpaid_orders' );
add_action( 'woocommerce_cancel_unpaid_orders', 'my_custom_wc_cancel_unpaid_orders' );
function my_custom_wc_cancel_unpaid_orders() {
global $wpdb;
$held_duration = get_option( 'woocommerce_hold_stock_minutes' );
if ( $held_duration < 1 || get_option( 'woocommerce_manage_stock' ) != 'yes' )
return;
$date = date( "Y-m-d H:i:s", strtotime( '-' . absint( $held_duration ) . ' MINUTES', current_time( 'timestamp' ) ) );
// write your own code here....
$unpaid_orders = $wpdb->get_col( $wpdb->prepare( "
SELECT posts.ID
FROM {$wpdb->posts} AS posts
WHERE posts.post_type IN ('" . implode( "','", wc_get_order_types() ) . "')
AND posts.post_status = 'wc-pending'
AND posts.post_modified < %s
", $date ) );
if ( $unpaid_orders ) {
foreach ( $unpaid_orders as $unpaid_order ) {
$order = wc_get_order( $unpaid_order );
if ( apply_filters( 'woocommerce_cancel_unpaid_order', 'checkout' === get_post_meta( $unpaid_order, '_created_via', true ), $order ) ) {
$order->update_status( 'cancelled', __( 'Unpaid order cancelled - time limit reached.', 'woocommerce' ) );
}
}
}
wp_clear_scheduled_hook( 'woocommerce_cancel_unpaid_orders' );
// do whatever you want here as well...
wp_schedule_single_event( time() + ( absint( $held_duration ) * 60 ), 'woocommerce_cancel_unpaid_orders' );
}
add_action('woocommerce_after_checkout_validation', 'deny_pobox_postcode');
function deny_pobox_postcode( $posted ) {
global $woocommerce;
$address = ( isset( $posted['shipping_address_1'] ) ) ? $posted['shipping_address_1'] : $posted['billing_address_1'];
$postcode = ( isset( $posted['shipping_postcode'] ) ) ? $posted['shipping_postcode'] : $posted['billing_postcode'];
$replace = array(" ", ".", ",");
$address = strtolower( str_replace( $replace, '', $address ) );
$postcode = strtolower( str_replace( $replace, '', $postcode ) );
if ( strstr( $address, 'pobox' ) || strstr( $postcode, 'pobox' ) ) {
$woocommerce->add_error( "Sorry, we don't ship to PO BOX addresses." );
}
}
i am getting:
fatal error :call to undefined add_error
when i am pasting on my function .php
add_error() has been renamed to wc_add_notice():
$woocommerce->wc_add_notice( "Sorry, we don't ship to PO BOX addresses." );
add_action('woocommerce_after_checkout_validation', 'deny_pobox_postcode');
function deny_pobox_postcode( $posted ) {
global $woocommerce;
$address = ( isset( $posted['shipping_address_1'] ) ) ?
$posted['shipping_address_1'] : $posted['billing_address_1'];
$postcode = ( isset( $posted['shipping_postcode'] ) ) ?
$posted['shipping_postcode'] : $posted['billing_postcode'];
$replace = array(" ", ".", ",");
$address = strtolower( str_replace( $replace, '', $address ) );
$postcode = strtolower( str_replace( $replace, '', $postcode ) );
if ( strstr( $address, 'pobox' ) || strstr( $postcode, 'pobox' ) ) {
$notice = sprintf( __( '%1$sSorry, we dont ship to PO BOX addresses..' , 'error' ) , '<strong>' , '</strong>' );
if ( version_compare( WC_VERSION, '2.3', '<' ) ) {
$woocommerce->add_error( $notice );
} else {
wc_add_notice( $notice, 'error' );
}
}
}
<?php
add_filter('woocommerce_package_rates',
'shomaris_hide_fedex_for_po_box_shipment',
10, 2);
function shomaris_hide_fedex_for_po_box_shipment($available_shipping_methods,
$package){
$shipping_method_to_hide = 'flat_rate:4';
// $shipping_method_to_hides = 'flat_rate:5';
global $woocommerce;
$address = ( !empty( $woocommerce->customer->get_shipping_address_1() ) ) ?
$woocommerce->customer->get_shipping_address_1() : $woocommerce->customer-
>get_billing_address_1();
$postcode = ( !empty( $woocommerce->customer->get_shipping_postcode() ) ) ?
$woocommerce->customer->get_shipping_postcode() : $woocommerce->customer-
>get_billing_postcode();
$replace = array(" ", ".", ",");
$address2 = strtolower( str_replace( $replace, '', $address ) );
if ( strstr( $address2, 'pobox' ) ) {
foreach ($available_shipping_methods as $shipping_method => $value) {
if( strpos( $shipping_method, $shipping_method_to_hide,
$shipping_method_to_hides ) !== false ) {
unset($available_shipping_methods[$shipping_method]);
}
}
}
return $available_shipping_methods;
}
?>