-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtemplate-tags.php
45 lines (36 loc) · 2.01 KB
/
template-tags.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
<?php
function woocommerce_wishlist_get_active_wishlist() {
if ( ! get_current_user_id() ) {
// if the user isn't logged in we want to use local storage
$return = false;
} else {
$return = WC_Wishlist_Query::get_wishlist_by_user();
$return = count( $return ) > 0 ? $return[0] : false;
}
return apply_filters( 'woocommerce_wishlist_get_active_wishlist', $return );
}
function woocommerce_wishlist_get_meta( $wishlist_id, $product_id = null, $meta_key = null ) {
return apply_filters( 'woocommerce_wishlist_get_meta', WC_Wishlist_Query_Meta::get( $wishlist_id, $product_id, $meta_key ) );
}
function woocommerce_wishlist_is_wishlist( $wishlist_id = null ) {
$wishlist_id = !is_null( $wishlist_id ) ? $wishlist_id : get_the_ID();
$status = get_post_type( $wishlist_id ) == WC_Wishlist::POST_TYPE ? true : false;
return apply_filters( 'woocommerce_wishlist_is_wishlist', $status );
}
function woocommerce_wishlist_add_meta( $wishlist_post_id, $product_id, $meta_key, $meta_value, $unique = true ) {
// make sure meta is added to the post, not a revision
// if ( $the_post = wp_is_post_revision( $wishlist_post_id ) )
// $wishlist_post_id = $the_post;
return apply_filters( 'woocommerce_wishlist_add_meta', WC_Wishlist_Query_Meta::add( $wishlist_post_id, $product_id, $meta_key, $meta_value, $unique ) );
}
function woocommerce_wishlist_delete_meta( $wishlist_post_id, $product_id = null, $meta_key = null, $meta_value = null ) {
return apply_filters( 'woocommerce_wishlist_delete_meta', WC_Wishlist_Query_Meta::delete( $wishlist_post_id, $product_id, $meta_key, $meta_value ) );
}
if ( !function_exists( 'woocommerce_wishlist_update_meta' ) ) {
function woocommerce_wishlist_update_meta( $wishlist_post_id, $product_id, $meta_key, $meta_value, $unique = true ) {
// make sure meta is added to the post, not a revision
// if ( $the_post = wp_is_post_revision( $wishlist_post_id ) )
// $wishlist_post_id = $the_post;
return WC_Wishlist_Query_Meta::update( $wishlist_post_id, $product_id, $meta_key, $meta_value, $unique );
}
}