/**
  * Add Menu Cart to menu
  * 
  * @return menu items including cart
  */
 public function submenu_items()
 {
     global $wpsc_cart, $options;
     $get_cart = wpsc_cart_item_count();
     $submenu_items = '';
     //see jigoshop/widgets/cart.php
     if (count($get_cart) > 0) {
         //foreach ( $get_cart as $cart_item_key => $values ) {
         while (wpsc_have_cart_items()) {
             wpsc_the_cart_item();
             //$_product = $values['data'];
             if (wpsc_cart_item_count() > 0) {
                 global $wpsc_cart, $options;
                 $item_thumbnail = '<img src=' . wpsc_cart_item_image() . '>';
                 $item_name = wpsc_cart_item_name();
                 $item_quantity = wpsc_cart_item_quantity();
                 $item_price = wpsc_cart_item_price();
                 // Item permalink
                 $item_permalink = wpsc_cart_item_url();
                 $submenu_items[] = array('item_thumbnail' => $item_thumbnail, 'item_name' => $item_name, 'item_quantity' => $item_quantity, 'item_price' => $item_price, 'item_permalink' => $item_permalink);
             }
             //}
         }
     } else {
         $submenu_items = '';
     }
     return $submenu_items;
 }
예제 #2
0
function widget_wp_shopping_cart($args)
{
    global $wpsc_theme_path, $cache_enabled;
    extract($args);
    $options = get_option('widget_wp_shopping_cart');
    if (get_option('show_sliding_cart') == 1) {
        if (is_numeric($_SESSION['slider_state'])) {
            if ($_SESSION['slider_state'] == 0) {
                $collapser_image = 'plus.png';
            } else {
                $collapser_image = 'minus.png';
            }
            $fancy_collapser = "<a href='#' onclick='return shopping_cart_collapser()' id='fancy_collapser_link'><img src='" . WPSC_URL . "/images/{$collapser_image}' title='' alt='' id='fancy_collapser' /></a>";
        } else {
            if ($_SESSION['nzshpcrt_cart'] == null) {
                $collapser_image = 'plus.png';
            } else {
                $collapser_image = 'minus.png';
            }
            $fancy_collapser = "<a href='#' onclick='return shopping_cart_collapser()' id='fancy_collapser_link'><img src='" . WPSC_URL . "/images/{$collapser_image}' title='' alt='' id='fancy_collapser' /></a>";
        }
    } else {
        $fancy_collapser = "";
    }
    $title = empty($options['title']) ? __('Shopping Cart') : $options['title'];
    echo $before_widget;
    $full_title = $before_title . $title . $fancy_collapser . $after_title;
    echo $full_title;
    $display_state = "";
    if (($_SESSION['slider_state'] == 0 || wpsc_cart_item_count() < 1) && get_option('show_sliding_cart') == 1) {
        $display_state = "style='display: none;'";
    }
    $use_object_frame = false;
    if ($cache_enabled == true && (!defined('DONOTCACHEPAGE') || constant('DONOTCACHEPAGE') !== true)) {
        echo "    <div id='sliding_cart' class='shopping-cart-wrapper'>";
        if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE") == false && $use_object_frame == true) {
            ?>
				<object codetype="text/html" type="text/html" data="index.php?wpsc_action=cart_html_page"  border='0px'>
					<p><?php 
            _e('Loading...', 'wpsc');
            ?>
</p>
				</object>
				<?php 
        } else {
            ?>
			<div class='wpsc_cart_loading'><p><?php 
            _e('Loading...', 'wpsc');
            ?>
</p>
			<?php 
        }
        echo "    </div>";
    } else {
        echo "    <div id='sliding_cart' class='shopping-cart-wrapper' {$display_state}>";
        include wpsc_get_theme_file_path("cart_widget.php");
        echo "    </div>";
    }
    echo $after_widget;
}
예제 #3
0
function wpsc_shopping_basket_internals($deprecated = false, $quantity_limit = false, $no_title = false)
{
    global $wpdb;
    $display_state = '';
    if ((isset($_SESSION['slider_state']) && $_SESSION['slider_state'] == 0 || wpsc_cart_item_count() < 1) && get_option('show_sliding_cart') == 1) {
        $display_state = "style='display: none;'";
    }
    echo "    <div id='sliding_cart' class='shopping-cart-wrapper' {$display_state}>";
    include_once wpsc_get_template_file_path('wpsc-cart_widget.php');
    echo '    </div>';
}
예제 #4
0
function wpsc_shopping_basket_internals($cart, $quantity_limit = false, $no_title = false)
{
    global $wpdb, $wpsc_theme_path;
    $display_state = "";
    if (($_SESSION['slider_state'] == 0 || wpsc_cart_item_count() < 1) && get_option('show_sliding_cart') == 1) {
        $display_state = "style='display: none;'";
    }
    echo "    <div id='sliding_cart' class='shopping-cart-wrapper' {$display_state}>";
    $cur_wpsc_theme_folder = apply_filters('wpsc_theme_folder', $wpsc_theme_path . WPSC_THEME_DIR);
    include_once $cur_wpsc_theme_folder . "/cart_widget.php";
    echo "    </div>";
    return $output;
}
예제 #5
0
function widget_wp_shopping_cart($args)
{
    global $wpsc_theme_path;
    extract($args);
    $options = get_option('widget_wp_shopping_cart');
    if (get_option('show_sliding_cart') == 1) {
        if (is_numeric($_SESSION['slider_state'])) {
            if ($_SESSION['slider_state'] == 0) {
                $collapser_image = 'plus.png';
            } else {
                $collapser_image = 'minus.png';
            }
            $fancy_collapser = "<a href='#' onclick='return shopping_cart_collapser()' id='fancy_collapser_link'><img src='" . WPSC_URL . "/images/{$collapser_image}' title='' alt='' id='fancy_collapser' /></a>";
        } else {
            if ($_SESSION['nzshpcrt_cart'] == null) {
                $collapser_image = 'plus.png';
            } else {
                $collapser_image = 'minus.png';
            }
            $fancy_collapser = "<a href='#' onclick='return shopping_cart_collapser()' id='fancy_collapser_link'><img src='" . WPSC_URL . "/images/{$collapser_image}' title='' alt='' id='fancy_collapser' /></a>";
        }
    } else {
        $fancy_collapser = "";
    }
    $title = empty($options['title']) ? __('Shopping Cart') : $options['title'];
    echo $before_widget;
    $full_title = $before_title . $title . $fancy_collapser . $after_title;
    echo $full_title;
    $display_state = "";
    if (($_SESSION['slider_state'] == 0 || wpsc_cart_item_count() < 1) && get_option('show_sliding_cart') == 1) {
        $display_state = "style='display: none;'";
    }
    echo "    <div id='sliding_cart' class='shopping-cart-wrapper' {$display_state}>";
    $cur_wpsc_theme_folder = apply_filters('wpsc_theme_folder', $wpsc_theme_path . WPSC_THEME_DIR);
    include $cur_wpsc_theme_folder . "/cart_widget.php";
    echo "    </div>";
    echo $after_widget;
}
예제 #6
0
function wpsc_cart_has_items()
{
    return wpsc_cart_item_count() >= 1;
}
예제 #7
0
function wpsc_get_cart()
{
    global $wpdb, $wpsc_cart;
    ob_start();
    include_once wpsc_get_template_file_path('wpsc-cart_widget.php');
    $output = ob_get_contents();
    ob_end_clean();
    $output = str_replace(array("\n", "\r"), array("\\n", "\\r"), addslashes($output));
    echo "jQuery('div.shopping-cart-wrapper').html('{$output}');\n";
    if (get_option('show_sliding_cart') == 1) {
        if (wpsc_cart_item_count() > 0 || count($cart_messages) > 0) {
            $_SESSION['slider_state'] = 1;
            echo "\n            jQuery('#sliding_cart').slideDown('fast',function(){\n               jQuery('#fancy_collapser').attr('src', (WPSC_CORE_IMAGES_URL+'/minus.png'));\n            });\n      ";
        } else {
            $_SESSION['slider_state'] = 0;
            echo "\n            jQuery('#sliding_cart').slideUp('fast',function(){\n               jQuery('#fancy_collapser').attr('src', (WPSC_CORE_IMAGES_URL+'/plus.png'));\n            });\n      ";
        }
    }
    do_action('wpsc_alternate_cart_html', '');
    exit;
}
예제 #8
0
/**
	* add_to_cart function, used through ajax and in normal page loading.
	* No parameters, returns nothing
*/
function wpsc_add_to_cart()
{
    global $wpdb, $wpsc_cart, $wpsc_theme_path;
    /// default values
    $default_parameters['variation_values'] = null;
    $default_parameters['quantity'] = 1;
    $default_parameters['provided_price'] = null;
    $default_parameters['comment'] = null;
    $default_parameters['time_requested'] = null;
    $default_parameters['custom_message'] = null;
    $default_parameters['file_data'] = null;
    $default_parameters['is_customisable'] = false;
    $default_parameters['meta'] = null;
    /// sanitise submitted values
    $product_id = (int) $_POST['product_id'];
    foreach ((array) $_POST['variation'] as $key => $variation) {
        $provided_parameters['variation_values'][(int) $key] = (int) $variation;
    }
    if ($_POST['quantity'] > 0 && !isset($_POST['wpsc_quantity_update'])) {
        $provided_parameters['quantity'] = (int) $_POST['quantity'];
    } else {
        if (isset($_POST['wpsc_quantity_update'])) {
            $wpsc_cart->remove_item($_POST['key']);
            $provided_parameters['quantity'] = (int) $_POST['wpsc_quantity_update'];
        }
    }
    //  exit('<pre>'.print_r($_POST, true).'</pre>');
    if ($_POST['is_customisable'] == 'true') {
        $provided_parameters['is_customisable'] = true;
        if (isset($_POST['custom_text'])) {
            $provided_parameters['custom_message'] = $_POST['custom_text'];
        }
        if (isset($_FILES['custom_file'])) {
            $provided_parameters['file_data'] = $_FILES['custom_file'];
        }
    }
    if ((double) $_POST['donation_price'] > 0) {
        $provided_parameters['provided_price'] = (double) $_POST['donation_price'];
    }
    $parameters = array_merge($default_parameters, (array) $provided_parameters);
    //echo "/*\n\r".print_r($parameters,true)."*/\n\r";
    $state = $wpsc_cart->set_item($product_id, $parameters);
    $product = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `id`='" . $product_id . "' LIMIT 1", ARRAY_A);
    if ($state == true) {
        $cart_messages[] = str_replace("[product_name]", stripslashes($product['name']), TXT_WPSC_YOU_JUST_ADDED);
    } else {
        if ($parameters['quantity'] <= 0) {
            $cart_messages[] = TXT_WPSC_ZERO_QUANTITY_REQUESTED;
        } else {
            if ($wpsc_cart->get_remaining_quantity($product_id, $parameters['variation_values'], $parameters['quantity']) > 0) {
                $cart_messages[] = str_replace("[number]", $wpsc_cart->get_remaining_quantity($product_id, $parameters['variation_values'], $parameters['quantity']), TXT_WPSC_INSUFFICIENT_REMAINING);
            } else {
                $cart_messages[] = str_replace("[product_name]", $product['name'], TXT_WPSC_SORRY_NONE_LEFT);
            }
        }
    }
    if ($_GET['ajax'] == 'true') {
        if ($product_id != null && get_option('fancy_notifications') == 1) {
            echo "if(jQuery('#fancy_notification_content')) {\n\r";
            echo "  jQuery('#fancy_notification_content').html(\"" . str_replace(array("\n", "\r"), array('\\n', '\\r'), addslashes(fancy_notification_content($cart_messages))) . "\");\n\r";
            echo "  jQuery('#loading_animation').css('display', 'none');\n\r";
            echo "  jQuery('#fancy_notification_content').css('display', 'block');\n\r";
            echo "}\n\r";
            $error_messages = array();
        }
        ob_start();
        $cur_wpsc_theme_folder = apply_filters('wpsc_theme_folder', $wpsc_theme_path . WPSC_THEME_DIR);
        include_once $cur_wpsc_theme_folder . "/cart_widget.php";
        $output = ob_get_contents();
        ob_end_clean();
        //exit("/*<pre>".print_r($wpsc_cart,true)."</pre>*/");
        $output = str_replace(array("\n", "\r"), array("\\n", "\\r"), addslashes($output));
        //echo '<pre>'.print_r($parameters,true).'</pre>';
        echo "jQuery('div.shopping-cart-wrapper').html('{$output}');\n";
        //  echo "jQuery('#wpsc_quantity_update').val('".$provided_parameters['quantity']."');\n";
        if (get_option('show_sliding_cart') == 1) {
            if (wpsc_cart_item_count() > 0 || count($cart_messages) > 0) {
                $_SESSION['slider_state'] = 1;
                echo "\n\t\t\t\t\tjQuery('#sliding_cart').slideDown('fast',function(){\n\t\t\t\t\t\tjQuery('#fancy_collapser').attr('src', (WPSC_URL+'/images/minus.png'));\n\t\t\t\t\t});\n\t\t\t";
            } else {
                $_SESSION['slider_state'] = 0;
                echo "\n\t\t\t\t\tjQuery('#sliding_cart').slideUp('fast',function(){\n\t\t\t\t\t\tjQuery('#fancy_collapser').attr('src', (WPSC_URL+'/images/plus.png'));\n\t\t\t\t\t});\n\t\t\t";
            }
        }
        do_action('wpsc_alternate_cart_html', $cart_messages);
        exit;
    }
}
    /**
     * Widget Output
     *
     * @param $args (array)
     * @param $instance (array) Widget values.
     *
     */
    function widget($args, $instance)
    {
        extract($args);
        // Create fancy collapser
        $fancy_collapser = '';
        if ($instance['show_sliding_cart'] == 1) {
            if (isset($_SESSION['slider_state']) && is_numeric($_SESSION['slider_state'])) {
                if ($_SESSION['slider_state'] == 0) {
                    $collapser_image = 'plus.png';
                } else {
                    $collapser_image = 'minus.png';
                }
                $fancy_collapser = ' <a href="#" onclick="return shopping_cart_collapser()" id="fancy_collapser_link"><img src="' . WPSC_CORE_IMAGES_URL . '/' . $collapser_image . '" title="" alt="" id="fancy_collapser" /></a>';
            } else {
                if (!wpsc_get_customer_meta('nzshpcart')) {
                    $collapser_image = 'plus.png';
                } else {
                    $collapser_image = 'minus.png';
                }
                $fancy_collapser = ' <a href="#" onclick="return shopping_cart_collapser()" id="fancy_collapser_link"><img src="' . WPSC_CORE_IMAGES_URL . '/' . $collapser_image . '" title="" alt="" id="fancy_collapser" /></a>';
            }
        }
        // Start widget output
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Shopping Cart', 'wpsc') : $instance['title']);
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $fancy_collapser . $after_title;
        }
        // Set display state
        $display_state = '';
        if ((isset($_SESSION['slider_state']) && $_SESSION['slider_state'] == 0 || wpsc_cart_item_count() < 1) && get_option('show_sliding_cart') == 1) {
            $display_state = 'style="display: none;"';
        }
        // Output start, if we are not allowed to save results ( WPSC_DONT_CACHE ) load the cart using ajax
        $use_object_frame = false;
        if (WPSC_PAGE_CACHE_IN_USE) {
            echo '<div id="sliding_cart" class="shopping-cart-wrapper">';
            if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') == false && $use_object_frame == true) {
                ?>
				<object codetype="text/html" type="text/html" data="index.php?wpsc_action=cart_html_page" border="0">
					<p><?php 
                _e('Loading...', 'wpsc');
                ?>
</p>
				</object>
				<?php 
            } else {
                ?>
				<div class="wpsc_cart_loading"><p><?php 
                _e('Loading...', 'wpsc');
                ?>
</p></div>
				<?php 
            }
            echo '</div>';
        } else {
            echo '<div id="sliding_cart" class="shopping-cart-wrapper" ' . $display_state . '>';
            include wpsc_get_template_file_path('wpsc-cart_widget.php');
            echo '</div>';
        }
        // End widget output
        echo $after_widget;
    }
예제 #10
0
        public function checkout_ids()
        {
            if (wpsc_cart_item_count() > 0) {
                global $wpsc_cart;
                $line_items = array();
                while (wpsc_have_cart_items()) {
                    wpsc_the_cart_item();
                    $current_item = $wpsc_cart->cart_item;
                    $parent = $this->get_parent_post($current_item->product_id);
                    if ($parent) {
                        $product_id = $parent->ID;
                        $product_name = $parent->post_title;
                    } else {
                        $product_id = wpsc_cart_item_product_id();
                        $product_name = wpsc_cart_item_name();
                    }
                    $line_item = (int) $product_id;
                    $line_items[] = $line_item;
                }
                echo '<script type="text/javascript">
			        var _ra = _ra || {};
			 	    _ra.checkoutIdsInfo =' . json_encode($line_items, JSON_PRETTY_PRINT) . '
			        if (_ra.ready !== undefined) {
				        _ra.checkoutIds(_ra.checkoutIdsInfo);
				  }
			</script>';
            }
        }
예제 #11
0
function wpsc_get_cart()
{
    global $wpdb, $wpsc_cart, $wpsc_theme_path;
    ob_start();
    $cur_wpsc_theme_folder = apply_filters('wpsc_theme_folder', $wpsc_theme_path . WPSC_THEME_DIR);
    include_once $cur_wpsc_theme_folder . "/cart_widget.php";
    $output = ob_get_contents();
    ob_end_clean();
    $output = str_replace(array("\n", "\r"), array("\\n", "\\r"), addslashes($output));
    echo "jQuery('div.shopping-cart-wrapper').html('{$output}');\n";
    if (get_option('show_sliding_cart') == 1) {
        if (wpsc_cart_item_count() > 0 || count($cart_messages) > 0) {
            $_SESSION['slider_state'] = 1;
            echo "\n\t\t\t\tjQuery('#sliding_cart').slideDown('fast',function(){\n\t\t\t\t\tjQuery('#fancy_collapser').attr('src', (WPSC_URL+'/images/minus.png'));\n\t\t\t\t});\n\t\t";
        } else {
            $_SESSION['slider_state'] = 0;
            echo "\n\t\t\t\tjQuery('#sliding_cart').slideUp('fast',function(){\n\t\t\t\t\tjQuery('#fancy_collapser').attr('src', (WPSC_URL+'/images/plus.png'));\n\t\t\t\t});\n\t\t";
        }
    }
    do_action('wpsc_alternate_cart_html', '');
    exit;
}
<?php

global $wpsc_cart, $wpdb, $wpsc_checkout, $wpsc_gateway, $wpsc_coupons, $wpsc_registration_error_messages;
$wpsc_checkout = new wpsc_checkout();
$alt = 0;
$coupon_num = wpsc_get_customer_meta('coupon');
if ($coupon_num) {
    $wpsc_coupons = new wpsc_coupons($coupon_num);
}
if (wpsc_cart_item_count() < 1) {
    echo __('Oops, there is nothing in your cart.', 'wp-e-commerce') . '<a href=' . esc_url(get_option('product_list_url', '')) . ">" . __('Please visit our shop', 'wp-e-commerce') . '</a>';
    return;
}
?>
<div id="checkout_page_container">
<h3><?php 
_e('Please review your order', 'wp-e-commerce');
?>
</h3>
<table class="checkout_cart">
   <tr class="header">
      <th colspan="2" ><?php 
_e('Product', 'wp-e-commerce');
?>
</th>
      <th><?php 
_e('Quantity', 'wp-e-commerce');
?>
</th>
      <th><?php 
_e('Price', 'wp-e-commerce');
예제 #13
0
 function jbst_wpec_cart_update()
 {
     $cart_count = wpsc_cart_item_count();
     $total = wpsc_cart_item_count() . ' item(s) - ' . wpsc_cart_total_widget();
     echo 'jQuery(".cart-contents").html("' . $total . '");';
 }
예제 #14
0
 /**
  * Comparing logic with the product information
  *
  * Checks if the product matchs the logic
  *
  * @return bool True if all conditions are matched, False otherwise.
  */
 function compare_logic($c, $product_obj)
 {
     global $wpdb, $wpsc_cart;
     if ($c['property'] == 'item_name') {
         $product_data = $wpdb->get_results("SELECT * FROM " . WPSC_TABLE_PRODUCT_LIST . " WHERE id='{$product_obj->product_id}'");
         $product_data = $product_data[0];
         switch ($c['logic']) {
             case 'equal':
                 //Checks if the product name is exactly the same as the condition value
                 if ($product_data->name == $c['value']) {
                     return true;
                 }
                 break;
             case 'greater':
                 //Checks if the product name is not the same as the condition value
                 if ($product_data->name > $c['value']) {
                     return true;
                 }
                 break;
             case 'less':
                 //Checks if the product name is not the same as the condition value
                 if ($product_data->name < $c['value']) {
                     return true;
                 }
                 break;
             case 'contains':
                 //Checks if the product name contains the condition value
                 preg_match("/(.*)" . $c['value'] . "(.*)/", $product_data->name, $match);
                 if (!empty($match)) {
                     return true;
                 }
                 break;
             case 'not_contain':
                 //Checks if the product name contains the condition value
                 preg_match("/(.*)" . $c['value'] . "(.*)/", $product_data->name, $match);
                 if (empty($match)) {
                     return true;
                 }
                 break;
             case 'begins':
                 //Checks if the product name begins with condition value
                 preg_match("/^" . $c['value'] . "/", $product_data->name, $match);
                 if (!empty($match)) {
                     return true;
                 }
                 break;
             case 'ends':
                 //Checks if the product name ends with condition value
                 preg_match("/" . $c['value'] . "\$/", $product_data->name, $match);
                 if (!empty($match)) {
                     return true;
                 }
                 break;
             case 'category':
                 //Checks if the product is in the category value
                 $category_flag = in_array($c['value'], $product_obj->category_id_list);
                 if ($category_flag == 1) {
                     $match = array($category_flag);
                     return true;
                 }
                 break;
             default:
                 return false;
         }
     } else {
         if ($c['property'] == 'item_quantity') {
             switch ($c['logic']) {
                 case 'equal':
                     //Checks if the quantity of a product in the cart equals condition value
                     if ($product_obj->quantity == (int) $c['value']) {
                         return true;
                     }
                     break;
                 case 'greater':
                     //Checks if the quantity of a product is greater than the condition value
                     if ($product_obj->quantity > $c['value']) {
                         return true;
                     }
                     break;
                 case 'less':
                     //Checks if the quantity of a product is less than the condition value
                     if ($product_obj->quantity < $c['value']) {
                         return true;
                     }
                     break;
                 case 'contains':
                     //Checks if the product name contains the condition value
                     preg_match("/(.*)" . $c['value'] . "(.*)/", $product_obj->quantity, $match);
                     if (!empty($match)) {
                         return true;
                     }
                     break;
                 case 'not_contain':
                     //Checks if the product name contains the condition value
                     preg_match("/(.*)" . $c['value'] . "(.*)/", $product_obj->quantity, $match);
                     if (empty($match)) {
                         return true;
                     }
                     break;
                 case 'begins':
                     //Checks if the product name begins with condition value
                     preg_match("/^" . $c['value'] . "/", $product_obj->quantity, $match);
                     if (!empty($match)) {
                         return true;
                     }
                     break;
                 case 'ends':
                     //Checks if the product name ends with condition value
                     preg_match("/" . $c['value'] . "\$/", $product_obj->quantity, $match);
                     if (!empty($match)) {
                         return true;
                     }
                     break;
                 case 'category':
                     //Checks if the product to see if its in the category
                     preg_match("/" . $c['value'] . "\$/", $product_obj->quantity, $match);
                     if (!empty($match)) {
                         return true;
                     }
                     break;
                 default:
                     return false;
             }
         } else {
             if ($c['property'] == 'total_quantity') {
                 $total_quantity = wpsc_cart_item_count();
                 //exit('Quantity :'.$total_quantity);
                 switch ($c['logic']) {
                     case 'equal':
                         //Checks if the quantity of products in the cart equals condition value
                         if ($total_quantity == $c['value']) {
                             return true;
                         }
                         break;
                     case 'greater':
                         //Checks if the quantity in the cart is greater than the condition value
                         if ($total_quantity > $c['value']) {
                             return true;
                         }
                         break;
                     case 'less':
                         //Checks if the quantity in the cart is less than the condition value
                         if ($total_quantity < $c['value']) {
                             return true;
                         }
                         break;
                     default:
                         return false;
                 }
             } else {
                 if ($c['property'] == 'subtotal_amount') {
                     $subtotal = wpsc_cart_total(false);
                     //exit('<pre>'.print_r($subtotal,true).'</pre>');
                     switch ($c['logic']) {
                         case 'equal':
                             //Checks if the subtotal of products in the cart equals condition value
                             if ($subtotal == $c['value']) {
                                 return true;
                             }
                             break;
                         case 'greater':
                             //Checks if the subtotal of the cart is greater than the condition value
                             //	exit('triggered here'.$subtotal.'>'.$c['value']);
                             if ($subtotal > $c['value']) {
                                 return true;
                             }
                             break;
                         case 'less':
                             //Checks if the subtotal of the cart is less than the condition value
                             if ($subtotal < $c['value']) {
                                 //exit('<pre>'.print_r($product_obj->cart->subtotal, true).'</pre>cValue'.$c['value']);
                                 return true;
                             } else {
                                 return false;
                             }
                             break;
                         default:
                             return false;
                     }
                 } else {
                     return apply_filters('wpsc_coupon_compare_logic', false, $c, $product_obj);
                 }
             }
         }
     }
 }
예제 #15
0
 /**
  * Comparing logic with the product information
  *
  * Checks if the product matchs the logic
  *
  * @return bool True if all conditions are matched, False otherwise.
  */
 function compare_logic($c, $product_obj)
 {
     global $wpdb;
     if ($c['property'] == 'item_name') {
         $product_data = $wpdb->get_results("SELECT * FROM " . $wpdb->posts . " WHERE id='{$product_obj->product_id}'");
         $product_data = $product_data[0];
         switch ($c['logic']) {
             case 'equal':
                 //Checks if the product name is exactly the same as the condition value
                 if ($product_data->post_title == $c['value']) {
                     return true;
                 }
                 break;
             case 'greater':
                 //Checks if the product name is not the same as the condition value
                 if ($product_data->post_title > $c['value']) {
                     return true;
                 }
                 break;
             case 'less':
                 //Checks if the product name is not the same as the condition value
                 if ($product_data->post_title < $c['value']) {
                     return true;
                 }
                 break;
             case 'contains':
                 //Checks if the product name contains the condition value
                 preg_match("/(.*)" . $c['value'] . "(.*)/", $product_data->post_title, $match);
                 if (!empty($match)) {
                     return true;
                 }
                 break;
             case 'category':
                 //Checks if the product category is the condition value
                 if ($product_data->post_parent) {
                     $categories = wp_get_post_terms($product_data->post_parent, 'wpsc_product_category');
                 } else {
                     $categories = wp_get_post_terms($product_data->ID, 'wpsc_product_category');
                 }
                 foreach ($categories as $cat) {
                     if (strtolower($cat->name) == strtolower($c['value'])) {
                         return true;
                     }
                 }
                 break;
             case 'not_contain':
                 //Checks if the product name contains the condition value
                 preg_match("/(.*)" . $c['value'] . "(.*)/", $product_data->post_title, $match);
                 if (empty($match)) {
                     return true;
                 }
                 break;
             case 'begins':
                 //Checks if the product name begins with condition value
                 preg_match("/^" . $c['value'] . "/", $product_data->post_title, $match);
                 if (!empty($match)) {
                     return true;
                 }
                 break;
             case 'ends':
                 //Checks if the product name ends with condition value
                 preg_match("/" . $c['value'] . "\$/", $product_data->post_title, $match);
                 if (!empty($match)) {
                     return true;
                 }
                 break;
             case 'category':
                 //Checks if the product name is in the set category
                 $product_categories = wp_get_post_terms($product_data->ID, 'wpsc_product_category');
                 foreach ($product_categories as $product_cat) {
                     if ($product_cat->name == $c['value']) {
                         return true;
                     }
                 }
                 break;
             default:
                 return false;
         }
     } else {
         if ($c['property'] == 'item_quantity') {
             switch ($c['logic']) {
                 case 'equal':
                     //Checks if the quantity of a product in the cart equals condition value
                     if ($product_obj->quantity == (int) $c['value']) {
                         return true;
                     }
                     break;
                 case 'greater':
                     //Checks if the quantity of a product is greater than the condition value
                     if ($product_obj->quantity > $c['value']) {
                         return true;
                     }
                     break;
                 case 'less':
                     //Checks if the quantity of a product is less than the condition value
                     if ($product_obj->quantity < $c['value']) {
                         return true;
                     }
                     break;
                 case 'contains':
                     //Checks if the product name contains the condition value
                     preg_match("/(.*)" . $c['value'] . "(.*)/", $product_obj->quantity, $match);
                     if (!empty($match)) {
                         return true;
                     }
                     break;
                 case 'not_contain':
                     //Checks if the product name contains the condition value
                     preg_match("/(.*)" . $c['value'] . "(.*)/", $product_obj->quantity, $match);
                     if (empty($match)) {
                         return true;
                     }
                     break;
                 case 'begins':
                     //Checks if the product name begins with condition value
                     preg_match("/^" . $c['value'] . "/", $product_obj->quantity, $match);
                     if (!empty($match)) {
                         return true;
                     }
                     break;
                 case 'ends':
                     //Checks if the product name ends with condition value
                     preg_match("/" . $c['value'] . "\$/", $product_obj->quantity, $match);
                     if (!empty($match)) {
                         return true;
                     }
                     break;
                 default:
                     return false;
             }
         } else {
             if ($c['property'] == 'total_quantity') {
                 $total_quantity = wpsc_cart_item_count();
                 switch ($c['logic']) {
                     case 'equal':
                         //Checks if the quantity of products in the cart equals condition value
                         if ($total_quantity == $c['value']) {
                             return true;
                         }
                         break;
                     case 'greater':
                         //Checks if the quantity in the cart is greater than the condition value
                         if ($total_quantity > $c['value']) {
                             return true;
                         }
                         break;
                     case 'less':
                         //Checks if the quantity in the cart is less than the condition value
                         if ($total_quantity < $c['value']) {
                             return true;
                         }
                         break;
                     default:
                         return false;
                 }
             } else {
                 if ($c['property'] == 'subtotal_amount') {
                     $subtotal = wpsc_cart_total(false);
                     switch ($c['logic']) {
                         case 'equal':
                             //Checks if the subtotal of products in the cart equals condition value
                             if ($subtotal == $c['value']) {
                                 return true;
                             }
                             break;
                         case 'greater':
                             //Checks if the subtotal of the cart is greater than the condition value
                             if ($subtotal > $c['value']) {
                                 return true;
                             }
                             break;
                         case 'less':
                             //Checks if the subtotal of the cart is less than the condition value
                             if ($subtotal < $c['value']) {
                                 return true;
                             } else {
                                 return false;
                             }
                             break;
                         default:
                             return false;
                     }
                 } else {
                     return apply_filters('wpsc_coupon_compare_logic', false, $c, $product_obj);
                 }
             }
         }
     }
 }
예제 #16
0
 public function menu_item()
 {
     global $wpsc_cart, $options;
     $menu_item = array('cart_url' => esc_url(get_option('shopping_cart_url')), 'shop_page_url' => esc_url(get_option('product_list_url')), 'cart_contents_count' => wpsc_cart_item_count(), 'cart_total' => wpsc_cart_total_widget(false, false, false));
     return $menu_item;
 }
예제 #17
0
        ?>
" />
					<input type="hidden" name="wpsc_update_quantity" value="true" />
					<input type='hidden' name='wpsc_ajax_action' value='wpsc_update_quantity' />
					<input class="remove_button" type="submit" />
				</form></td>
			</tr>
		<?php 
    }
    ?>
		</tbody>
		<tfoot>
			<tr class="cart-widget-total">
				<td class="cart-widget-count">
					<?php 
    printf(_n('%d item', '%d items', wpsc_cart_item_count(), 'wp-e-commerce'), wpsc_cart_item_count());
    ?>
				</td>
				<td class="pricedisplay checkout-total" colspan='4'>
					<?php 
    _e('Subtotal:', 'wp-e-commerce');
    ?>
 <?php 
    echo wpsc_cart_total_widget(false, false, false);
    ?>
<br />
					<small><?php 
    _e('excluding discount, shipping and tax', 'wp-e-commerce');
    ?>
</small>
				</td>
예제 #18
0
 function calculate_discount()
 {
     global $wpdb, $wpsc_cart;
     $wpsc_cart->clear_cache();
     //Calculates the discount for the whole cart if there is no condition on this coupon.
     if ($this->conditions == '' || count($this->conditions) == 0) {
         // $this->is_percentage == '2' means "Free Shipping"
         if ($this->is_percentage == '2') {
             return $wpsc_cart->calculate_total_shipping();
         }
         // $this->is_percentage == '1' means "%" discount
         if ($this->is_percentage == '1') {
             $total_price = $wpsc_cart->calculate_subtotal();
             $this->discount = $total_price * $this->value / 100;
             return $this->discount;
             // Anything else means "Fixed amount" discount
         } else {
             if ($this->every_product == 1) {
                 $item_count = (int) wpsc_cart_item_count();
                 return $this->value * $item_count;
             } else {
                 return $this->value;
             }
         }
         // The coupon has conditions so may not apply to all items
     } else {
         //Loop throught all products in the shopping cart, apply coupons on the ones match the conditions.
         $cart =& $wpsc_cart->have_cart_items();
         foreach ($wpsc_cart->cart_items as $key => $item) {
             $product_data = $wpdb->get_results("SELECT * FROM " . $wpdb->posts . " WHERE id='{$item->product_id}'");
             $product_data = $product_data[0];
             $match = true;
             foreach ($this->conditions as $c) {
                 //Check if all the condictions are returning true, so it's an ALL logic, if anyone want to implement a ANY logic please do.
                 if (!$this->compare_logic($c, $item)) {
                     $match = false;
                     break;
                 }
             }
             // This product is eligible for discount
             if ($match) {
                 if ($this->is_percentage == '1') {
                     $this->discount = $item->unit_price * $item->quantity * $this->value / 100;
                     $item->discount = $this->discount;
                     if ($this->every_product == 1) {
                         $return += $this->discount;
                     } else {
                         return $this->discount;
                     }
                 } else {
                     $item->discount = $this->value;
                     if ($this->every_product == 1) {
                         $return += $item->discount;
                     } else {
                         return $item->discount;
                     }
                 }
                 // This product is not eligible for discount
             } else {
                 $this->discount = 0;
                 $item->discount = $this->discount;
                 $return += $this->discount;
             }
         }
     }
     return $return;
 }
예제 #19
0
        ?>
" />
					<input type="hidden" name="wpsc_update_quantity" value="true" />
					<input type='hidden' name='wpsc_ajax_action' value='wpsc_update_quantity' />
					<input class="remove_button" type="submit" />
				</form></td>
			</tr>
		<?php 
    }
    ?>
		</tbody>
		<tfoot>
			<tr class="cart-widget-total">
				<td class="cart-widget-count">
					<?php 
    printf(_n('%d item', '%d items', wpsc_cart_item_count(), 'wpsc'), wpsc_cart_item_count());
    ?>
				</td>
				<td class="pricedisplay checkout-total" colspan='4'>
					<?php 
    _e('Subtotal:', 'wpsc');
    ?>
 <?php 
    echo wpsc_cart_total_widget(false, false, false);
    ?>
<br />
					<small><?php 
    _e('excluding discount, shipping and tax', 'wpsc');
    ?>
</small>
				</td>
예제 #20
0
                <div class="small-circle"></div>

                <div class="nav">
                    <span><a href="<?php 
bloginfo('home');
?>
">HOME</a></span>
                    <span><a href="<?php 
bloginfo('home');
?>
/all-exhibitions">EXHIBITIONS</a></span>
                    <span><a href="<?php 
bloginfo('home');
?>
/shop">SHOP</a></span>
                    <span><a href="http://seetheunseen.co.uk/enter" target="_blank">STUDIO</a></span>
                    <span class="basket"><a href="<?php 
bloginfo('home');
?>
/shop/checkout">BASKET <div class="itemcount">(<?php 
echo wpsc_cart_item_count();
?>
)</div></a></span>
                </div>

            </div>

        </div>

        <div class="container">
      
예제 #21
0
 /**
  * add a custom AJAX request handler
  */
 function sfpaper_theme_wpsc_cart_update()
 {
     $data = array('cart_count' => wpsc_cart_item_count(), 'cart_total' => wpsc_cart_total_widget());
     echo json_encode($data);
     exit;
 }
예제 #22
0
 function calculate_discount()
 {
     global $wpdb, $wpsc_cart;
     //echo "<pre>".print_r($wpsc_cart,true)."</pre>";
     $wpsc_cart->clear_cache();
     if ($this->conditions == '' || count($this->conditions) == 0) {
         //Calculates the discount for the whole cart if there is no condition on this coupon.
         if ($this->is_percentage == '1') {
             $total_price = $wpsc_cart->calculate_subtotal();
             $this->discount = $total_price * $this->value / 100;
             return $this->discount;
         } else {
             if ($this->every_product == 1) {
                 $item_count = (int) wpsc_cart_item_count();
                 return $this->value * $item_count;
             } else {
                 return $this->value;
             }
         }
     } else {
         //Loop throught all products in the shopping cart, apply coupons on the ones match the conditions.
         $cart =& $wpsc_cart->have_cart_items();
         //	exit('<pre>'.print_r($cart->, true).'</pre>');
         /*
         foreach($wpsc_cart->cart_items as $key => $cart_item) {
         				echo '<pre>'.print_r($cart_item, true).'</pre>';
         			}
         */
         //exit('<pre>'.print_r($this, true).'</pre>');
         foreach ($wpsc_cart->cart_items as $key => $item) {
             $match = true;
             $product_data = $wpdb->get_results("SELECT * FROM " . WPSC_TABLE_PRODUCT_LIST . " WHERE id='{$item->product_id}'");
             $product_data = $product_data[0];
             foreach ($this->conditions as $c) {
                 //Check if all the condictions are returning true, so it's an ALL logic, if anyone want to implement a ANY logic please do.
                 /* $match && */
                 $match = $this->compare_logic($c, $item);
                 if ($match) {
                     $match = true;
                     //	exit('ture');
                 } else {
                     $match = false;
                     //	exit('false');
                 }
             }
             if ($match) {
                 if ($this->is_percentage == '1') {
                     $this->discount = $item->unit_price * $item->quantity * $this->value / 100;
                     $item->discount = $this->discount;
                     if ($this->every_product == 1) {
                         $return += $this->discount;
                     } else {
                         return $this->discount;
                     }
                     //echo $item->discount."-";
                 } else {
                     $item->discount = $this->value;
                     if ($this->every_product == 1) {
                         $return += $this->discount;
                     } else {
                         //exit('<pre>'.print_r($this,true).'</pre>');
                         return $this->value;
                     }
                     //$return += $this->value;
                 }
             } else {
                 //exit('match not found');
                 $this->discount = 0;
                 $item->discount = $this->discount;
                 $return += $this->discount;
             }
         }
     }
     return $return;
 }
예제 #23
0
/**
 * Returns the Cart Widget
 *
 * @param  boolean $die          Whether or not to return the output (for new JSON requests) or to die() on the old $output / action.
 * @param  array   $cart_message An array of cart messages to be optionally passed.  Primarily passed via wpsc_add_to_cart().
 *
 * @since 3.8.11
 * @return mixed                 Returns an array of output data, alternatively
 */
function _wpsc_ajax_get_cart($die = true, $cart_messages = array())
{
    $return = array();
    if (defined('DOING_AJAX') && DOING_AJAX) {
        ob_start();
        include_once wpsc_get_template_file_path('wpsc-cart_widget.php');
        $output = ob_get_contents();
        ob_end_clean();
        $output = str_replace(array('\\n', '\\r'), '', $output);
        $return['widget_output'] = $output;
        $return['core_images_url'] = WPSC_CORE_IMAGES_URL;
        if (1 == get_option('show_sliding_cart') || empty($cart_messages)) {
            if (wpsc_cart_item_count()) {
                $_SESSION['slider_state'] = 1;
                $return['sliding_cart_state'] = 'show';
            } else {
                $_SESSION['slider_state'] = 0;
                $return['sliding_cart_state'] = 'hide';
            }
        }
        $action_output = '';
        if (has_action('wpsc_alternate_cart_html') && empty($_REQUEST['_wpsc_compat_ajax'])) {
            //Deprecated action. Do not use.  We now have a custom JS event called 'wpsc_fancy_notification'. There is access to the complete $json_response object.
            ob_start();
            echo _wpsc_get_alternate_html($cart_messages);
            $action_output = ob_get_contents();
            $output = '';
            ob_end_clean();
        }
        if (!empty($action_output)) {
            _wpsc_doing_it_wrong('wpsc_alternate_cart_html', __('As of WPeC 3.8.11, it is improper to hook into "wpsc_alternate_cart_html" to output javascript.  We now have a custom javascript event called "wpsc_fancy_notification" you can hook into.', 'wpsc'), '3.8.11');
            $return['wpsc_alternate_cart_html'] = $action_output;
        }
    }
    if ($die) {
        echo $output . $action_output;
        die;
    } else {
        return $return;
    }
}
예제 #24
0
<?php

global $wpsc_cart, $wpdb, $wpsc_checkout, $wpsc_gateway, $wpsc_coupons;
$wpsc_checkout = new wpsc_checkout();
$wpsc_gateway = new wpsc_gateways();
$wpsc_coupons = new wpsc_coupons($_SESSION['coupon_numbers']);
//echo "<pre>".print_r($wpsc_cart,true)."</pre>";
if (wpsc_cart_item_count() > 0) {
    ?>
<p><?php 
    echo TXT_WPSC_REVIEW_YOUR_ORDER;
    ?>
</p>
<table class="productcart">
	<tr class="firstrow">
		<td class='firstcol'></td>
		<td><?php 
    echo TXT_WPSC_PRODUCT;
    ?>
:</td>
		<td><?php 
    echo TXT_WPSC_QUANTITY;
    ?>
:</td>
		<td><?php 
    echo TXT_WPSC_PRICE;
    ?>
:</td>
		<td></td>
	</tr>
	<?php 
예제 #25
0
/**
 * Checks if the current cart is a "Free Cart", which means one of the following:
 *
 *  - Either the all of the cart items are priced at 0.
 *  - Or a coupon has been applied that results in a free cart.
 *
 * This is a helpful function for doing things like allowing free carts to be purchased, bypassing payment gateways.
 *
 * @since  3.9.0
 * @return bool Whether or not the current cart's total cost is free or not.
 */
function wpsc_is_free_cart()
{
    return apply_filters('wpsc_is_free_cart', wpsc_cart_item_count() && !floatval(wpsc_cart_total(false)));
}