-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-functions.php
50 lines (36 loc) · 1.58 KB
/
wp-functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
// Show Delivery Windows on Product Pages
add_action( 'woocommerce_after_add_to_cart_button', 'show_shipping_cart', 2 );
function show_shipping_cart() {
$product_classes = wp_get_post_terms( get_the_ID(), 'product_shipping_class' );
if ( $product_classes && ! is_wp_error ( $product_classes ) ){
$single_class = array_shift( $product_classes ); ?>
<p class="shipping_class_desc"><?php echo 'Delivery: '.$single_class->description; ?></p><?php
}
}
// Show Delivery Windows on Product Pages (ALT)
function show_shipping_on_product_page() {
$product = wc_get_product();
$shipping_class = $product->get_shipping_class();
switch ( $shipping_class ) {
default:
echo '<div class="woocommerce-info">Delivery: 1-2 Weeks</div>';
break;
case 'vendor-1':
echo '<div class="woocommerce-info">Delivery: 4-5 Weeks</div>';
break;
case 'vendor-2':
echo '<div class="woocommerce-info">Delivery: 3-5 Weeks</div>';
break;
case 'vendor-3': // Enter shipping class slug
echo '<div class="woocommerce-info">Delivery: 5-10 Weeks</div>'; // Edit "Delivery: xxx"
break;
}
}
add_action( 'woocommerce_after_add_to_cart_button', 'show_shipping_on_product_page', 20 );
// Show Delivery Notice on Checkout Page
add_action( 'woocommerce_review_order_after_submit', 'message_below_checkout_button' );
function message_below_checkout_button() {
echo '<p><small>When ordering multiple items, it\'s possible they will ship separately</small></p>';
}
?>