Exemplo n.º 1
0
function wpmp_get_cart_discount()
{
    global $current_user;
    get_currentuserinfo();
    $role = $current_user->roles[0];
    $role = $role ? $role : 'guest';
    //$subtotal = wpmp_get_cart_subtotal();
    $cart_items = wpmp_get_cart_items();
    $discount_r = 0;
    //print_r($cart_items);
    foreach ($cart_items as $pid => $item) {
        $opt = get_post_meta($pid, 'wpmp_list_opts', true);
        //print_r($opt);
        $prices = 0;
        $lprices = array();
        @extract(get_post_meta($pid, "wpmp_list_opts", true));
        foreach ($variation as $key => $value) {
            foreach ($value as $optionkey => $optionvalue) {
                if ($optionkey != "vname" && $optionkey != 'multiple') {
                    if ($item['variation']) {
                        foreach ($item['variation'] as $var) {
                            if ($var == $optionkey) {
                                $prices += $optionvalue['option_price'];
                            }
                        }
                    } elseif (isset($item['item']) && !empty($item['item'])) {
                        foreach ($item['item'] as $a => $b) {
                            //different variations, $b is single variation contain variation and quantity
                            if ($b['variation']) {
                                //$lprices[$a] = 0;
                                foreach ($b['variation'] as $c) {
                                    if ($c == $optionkey) {
                                        $lprices[$a] += $optionvalue['option_price'];
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if (!empty($lprices)) {
            foreach ($lprices as $key => $val) {
                $discount_r += ($item['price'] + $val) * $item['item'][$key]['quantity'] * $opt['discount'][$role] / 100;
            }
        } else {
            $discount_r += ($item['price'] + $prices) * $item['quantity'] * $opt['discount'][$role] / 100;
        }
    }
    return number_format($discount_r, 2, ".", "");
}
Exemplo n.º 2
0
   
<div class="checkout_div wp-marketplace">
    <?php 
global $current_user, $sap;
get_currentuserinfo();
$cart_items = wpmp_get_cart_items();
$currency_sign = get_option('_wpmp_curr_sign', '$');
if (count($cart_items) == 0) {
    echo __("No item in cart.", "wpmarketplace") . "<br/><a href='" . $settings['continue_shopping_url'] . "'>" . __("Continue shopping", "wpmarketplace") . "</a></div>";
} else {
    $settings = maybe_unserialize(get_option('_wpmp_settings'));
    include_once "checkout_method.php";
    include_once "billing.php";
    //include_once("shipping_method.php");
    //include_once("payment_method.php");
    //include_once("order_review.php");
    ?>
             
     <div id="wpmp-section-shipping">     
     <div class="step-title">
            <h2><?php 
    echo __("Shipping Method", "wpmarketplace");
    ?>
</h2>
     </div>
      <div id="shipping">
      </div>
     </div>

     <div id="wpmp-section-payment">     
     <div class="step-title">