-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathurban-angels-woocommerce.php
104 lines (82 loc) · 2.75 KB
/
urban-angels-woocommerce.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
/**
* @package Urban Angels WooCommerce
* @version 1.0
*/
/*
Plugin Name: Urban Angels WooCommerce
Plugin URI: http://urbanangels.co.uk/
Description: Features for WooCommerce
Author: Sue Johnson
Version: 1.0
Author URI: http://suesdesign.co.uk/
*/
/**
* Change 'Add to Basket' to 'Buy Now' or 'Book now' on classes category
*/
// Change add to basket button text per category
add_filter( 'woocommerce_product_single_add_to_cart_text', 'urbanangels_custom_cart_button_text' );
function urbanangels_custom_cart_button_text() {
global $product;
if ( has_term( 'Classes', 'product_cat', $product->get_id() ) && $product->is_in_stock() ) {
return 'Book now';
} else {
return 'Buy now';
}
}
// Change add to basket button text per category archive pages
add_filter( 'woocommerce_product_add_to_cart_text', 'urbanangels_archive_custom_cart_button_text' );
function urbanangels_archive_custom_cart_button_text() {
global $product;
if ( has_term( 'Classes', 'product_cat', $product->get_id() ) && $product->is_in_stock() ) {
return 'Book now';
} else if ( !$product->is_in_stock() ) {
return 'Sold out';
} else {
return 'Buy now';
}
}
/**
* Remove the breadcrumbs
*/
add_action( 'init', 'woo_remove_wc_breadcrumbs' );
function woo_remove_wc_breadcrumbs() {
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
}
/**
* Remove the sidebar
*/
add_action('init', 'disable_woo_commerce_sidebar');
function disable_woo_commerce_sidebar() {
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10);
}
/**
* Exclude categories from showing
*/
add_action('init', 'urbanangels_disable_meta');
function urbanangels_disable_meta() {
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
}
/**
* Change 'in stock' and 'out of stock' to 'available' and 'sold out'
*/
add_filter( 'woocommerce_get_availability_text', 'urbanangels_custom_get_availability_text', 99, 2 );
function urbanangels_custom_get_availability_text( $availability, $product ) {
$stock = $product->get_stock_quantity();
if ( $product->is_in_stock() && $product->managing_stock() && get_option( 'woocommerce_stock_format' ) == '' ){
$availability = __( $stock . ' Available', 'woocommerce' );
return $availability;
} else if ( !$product->is_in_stock() ) {
return 'Sold out';
}
}
/**
* Remove product data tabs
*/
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
unset( $tabs['description'] ); // Remove the description tab
unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
return $tabs;
}