Exemple #1
0
/**
 * Ajax wishlist
 */
header("Cache-Control: no-cache, must-revalidate");
// HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
// Date in the past
global $king;
include dirname(__FILE__) . DS . 'functions-wishlist.php';
if (!isset($king_wishlist)) {
    $king_wishlist = new king_WISHLIST($_REQUEST);
}
// Remove product from the wishlist
if ($_GET['action'] == 'remove_from_wishlist') {
    $count = king_wishlist_count_products();
    if ($king_wishlist->remove($_GET['wishlist_item_id'])) {
        _e('Product successfully removed.', 'king');
    } else {
        echo '#' . $count . '#';
        _e('Error. Unable to remove the product from the wishlist.', 'king');
    }
    if (!$count) {
        _e('No products were added to the wishlist', 'king');
    }
    wp_redirect($king_wishlist->get_wishlist_url());
    die;
} elseif ($_GET['action'] == 'add_to_wishlist') {
    $return = $king_wishlist->add();
    if ($return == 'true') {
        print $return . '##' . __('Product added!', 'king');
Exemple #2
0
 /**
  * AJAX: remove from wishlist action
  */
 public function remove_from_wishlist_ajax()
 {
     $count = king_wishlist_count_products();
     if ($this->remove($_GET['wishlist_item_id'])) {
         echo apply_filters('king_wishlist_product_removed_text', __('Product successfully removed.', 'king'));
     } else {
         echo '#' . $count . '#';
         _e('Error. Unable to remove the product from the wishlist.', 'king');
     }
     if (!$count) {
         _e('No products were added to the wishlist', 'king');
     }
     die;
 }