当前位置: 首页>>代码示例>>PHP>>正文


PHP calculate_total函数代码示例

本文整理汇总了PHP中calculate_total函数的典型用法代码示例。如果您正苦于以下问题:PHP calculate_total函数的具体用法?PHP calculate_total怎么用?PHP calculate_total使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了calculate_total函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: foreach

 foreach ($stateList as $code => $value) {
     $eshopstatelist[$value['id']] = $value['code'];
 }
 foreach ($_POST as $name => $value) {
     //have to do a discount code check here - otherwise things just don't work - but fine for free shipping codes
     if (strstr($name, 'amount_')) {
         if (isset($_SESSION['eshop_discount' . $blog_id]) && eshop_discount_codes_check()) {
             $chkcode = valid_eshop_discount_code($_SESSION['eshop_discount' . $blog_id]);
             if ($chkcode && apply_eshop_discount_code('discount') > 0) {
                 $discount = apply_eshop_discount_code('discount') / 100;
                 $value = number_format(round($value - $value * $discount, 2), 2);
                 $vset = 'yes';
             }
         }
         if (is_discountable(calculate_total()) != 0 && !isset($vset)) {
             $discount = is_discountable(calculate_total()) / 100;
             $value = number_format(round($value - $value * $discount, 2), 2);
         }
     }
     if (sizeof($stateList) > 0 && ($name == 'state' || $name == 'ship_state')) {
         if ($value != '') {
             $value = $eshopstatelist[$value];
         }
     }
     $p->add_field($name, $value);
 }
 //	$p->add_field('return_method','2'); //1=GET 2=POST
 // was return method now rm - go figure.
 $p->add_field('rm', '2');
 //1=GET 2=POST
 //settings in paypal/index.php to change these
开发者ID:ricasiano,项目名称:mca-site,代码行数:31,代码来源:paypal.php

示例2: eshop_checkout


//.........这里部分代码省略.........
             }
             if (isset($espost['ship_country'])) {
                 $ship_country = $espost['ship_country'];
             }
             if (isset($espost['ship_state'])) {
                 $ship_state = $espost['ship_state'];
             }
             if (isset($espost['ship_altstate'])) {
                 $ship_altstate = $espost['ship_altstate'];
             }
             if (isset($espost['ship_postcode'])) {
                 $ship_postcode = $espost['ship_postcode'];
             }
             if (isset($espost['comments'])) {
                 $comments = $espost['comments'];
             }
             $chkerror = '1';
         } else {
             if (!isset($_GET['eshopaction'])) {
                 $shipping = 0;
                 $echoit .= "<div class=\"hr\"></div><div class=\"eshopcheckoutconf\"><h3>" . __('<span class="noprint">Please Confirm </span>Your Details', 'eshop') . '</h3>';
                 // create a custom id, and shove details in database
                 $date = date('YmdHis');
                 $_SESSION['date' . $blog_id] = $date;
                 $fprice = number_format($_SESSION['final_price' . $blog_id], 2, '.', '');
                 $espost['amount'] = $fprice;
                 $espost['custom'] = $date;
                 $espost['numberofproducts'] = sizeof($_SESSION['eshopcart' . $blog_id]);
                 //shipping
                 if (isset($_SESSION['shipping' . $blog_id])) {
                     $shipping = eshopShipTaxAmt();
                 }
                 //discount shipping
                 if (is_shipfree(calculate_total())) {
                     $shipping = 0;
                 }
                 //shipping
                 $espost['shipping_1'] = $shipping;
                 $ctable = $wpdb->prefix . 'eshop_countries';
                 $stable = $wpdb->prefix . 'eshop_states';
                 if ('no' == $eshopoptions['downloads_only']) {
                     $echoit .= '<h4>' . __('Mailing Address', 'eshop') . '</h4><ul class="eshop confirm">';
                 } else {
                     $echoit .= '<h4>' . __('Contact Details', 'eshop') . '</h4><ul class="eshop confirm">';
                 }
                 $echoit .= "<li><span class=\"items fullname\">" . __('Full name:', 'eshop') . "</span> " . $espost['first_name'] . " " . $espost['last_name'] . "</li>\n";
                 if ('no' == $eshopoptions['downloads_only']) {
                     $echoit .= "<li class=\"company\"><span class=\"items\">" . __('Company:', 'eshop') . "</span> " . $espost['company'] . "</li>\n";
                 }
                 $echoit .= "<li class=\"email\"><span class=\"items\">" . __('Email:', 'eshop') . "</span> " . $espost['email'] . "</li>\n";
                 if ('no' == $eshopoptions['downloads_only']) {
                     $echoit .= "<li class=\"phone\"><span class=\"items\">" . __('Phone:', 'eshop') . "</span> " . $espost['phone'] . "</li>\n";
                     $echoit .= "<li class=\"address\"><span class=\"items\">" . __('Address:', 'eshop') . "</span> " . $espost['address1'] . " " . $espost['address2'] . "</li>\n";
                     $echoit .= "<li class=\"city\"><span class=\"items\">" . __('City or town:', 'eshop') . "</span> " . $espost['city'] . "</li>\n";
                     $qcode = $wpdb->escape($espost['state']);
                     $qstate = $wpdb->get_var("SELECT stateName FROM {$stable} WHERE id='{$qcode}' limit 1");
                     if ($espost['altstate'] != '') {
                         $echoit .= "<li class=\"state\"><span class=\"items\">" . __('State/County/Province:', 'eshop') . "</span> " . $espost['altstate'] . "</li>\n";
                     } elseif ($qstate != '') {
                         $echoit .= "<li class=\"state\"><span class=\"items\">" . __('State/County/Province:', 'eshop') . "</span> " . $qstate . "</li>\n";
                     }
                     $echoit .= "<li class=\"zip\"><span class=\"items\">" . __('Zip/Post code:', 'eshop') . "</span> " . $espost['zip'] . "</li>\n";
                     $qccode = $wpdb->escape($espost['country']);
                     $qcountry = $wpdb->get_var("SELECT country FROM {$ctable} WHERE code='{$qccode}' limit 1");
                     $echoit .= "<li class=\"country\"><span class=\"items\">" . __('Country:', 'eshop') . "</span> " . $qcountry . "</li>\n";
                 }
开发者ID:ricasiano,项目名称:mca-site,代码行数:67,代码来源:checkout.php

示例3: display_cart


//.........这里部分代码省略.........
                        $data = eshop_parse_optsets($data);
                        $optset = '<span class="eshopoptsets">' . $data['optset'] . '</span>';
                        $addoprice = $data['addoprice'];
                    } else {
                        $optset = '';
                    }
                    $echooptset = apply_filters('eshop_optset_cart_display', $optset);
                    if (!has_filter('eshop_optset_cart_display')) {
                        $echooptset = nl2br($optset);
                    }
                    $textdesc = '<a href="' . get_permalink($opt['postid']) . '">' . stripslashes($opt["pname"]) . ' <span class="eshopidetails">(' . $opt['pid'] . ' : ' . stripslashes($opt['item']) . ')</span></a>' . $echooptset;
                    $echoimg = $eimg;
                    if (isset($eshopoptions['widget_cart_type']) && $eshopoptions['widget_cart_type'] == '1' && $iswidget == 'w') {
                        $textdesc = '';
                    }
                    if ($iswidget == 'w' && isset($eshopoptions['widget_cart_type']) && $eshopoptions['widget_cart_type'] == '2') {
                        $echoimg = '';
                    }
                    $echo .= '<td id="prod' . $calt . $iswidget . '" headers="cartItem' . $iswidget . '" class="leftb cartitem">' . $echoimg . $textdesc . '</td>' . "\n";
                    $echo .= "<td class=\"cqty lb\" headers=\"cartQty{$iswidget} prod" . $calt . $iswidget . "\">";
                    // if we allow changes, quantities are in text boxes
                    if ($change == true) {
                        //generate acceptable id
                        //$toreplace=array(" ","-","$","\r","\r\n","\n","\\","&","#",";");
                        $accid = $productid . $key;
                        $accid = 'c' . md5($accid);
                        //str_replace($toreplace, "", $accid);
                        $echo .= '<label for="' . $accid . $iswidget . '"><input class="short" type="text" id="' . $accid . $iswidget . '" name="' . $productid . '[' . $key . ']" value="' . $opt["qty"] . '" size="3" maxlength="3" /></label>';
                    } else {
                        $echo .= $opt["qty"];
                    }
                    /* DISCOUNT */
                    $opt["price"] += $addoprice;
                    if (is_discountable(calculate_total()) > 0) {
                        $discount = is_discountable(calculate_total()) / 100;
                        $disc_line = round($opt["price"] - $opt["price"] * $discount, 2);
                    }
                    $eline = $line_total = $opt["price"] * $opt["qty"];
                    if (isset($disc_line)) {
                        $eline = $disc_line * $opt["qty"];
                    }
                    $echo .= "</td>\n<td headers=\"cartTotal{$iswidget} prod" . $calt . $iswidget . "\" class=\"amts\">" . sprintf(__('%1$s%2$s', 'eshop'), $currsymbol, number_format_i18n($eline, __('2', 'eshop'))) . "</td>\n";
                    //TAX
                    $etax = $eshopoptions['etax'];
                    if ($pzone != '' && isset($eshopoptions['tax']) && $eshopoptions['tax'] == '1' || 'yes' == $eshopoptions['downloads_only'] && isset($etax['unknown']) && $etax['unknown'] != '') {
                        if (isset($eshop_product['products'][$opt['option']]['tax']) && $eshop_product['products'][$opt['option']]['tax'] != '' && $eshop_product['products'][$opt['option']]['tax'] != '0') {
                            if ($pzone != '') {
                                $taxrate = eshop_get_tax_rate($eshop_product['products'][$opt['option']]['tax'], $pzone);
                            } else {
                                $taxrate = $etax['unknown'];
                            }
                            $ttotax = $line_total;
                            if (isset($disc_line)) {
                                $ttotax = $disc_line * $opt["qty"];
                            }
                            $taxamt = round($ttotax * $taxrate / 100, 2);
                            $echo .= '<td>' . $taxrate . '</td><td>' . sprintf(__('%1$s%2$s', 'eshop'), $currsymbol, number_format_i18n($taxamt, __('2', 'eshop'))) . '</td>';
                            $taxtotal += $taxamt;
                            $_SESSION['eshopcart' . $blog_id][$productid]['tax_rate'] = $taxrate;
                            $_SESSION['eshopcart' . $blog_id][$productid]['tax_amt'] = $taxamt;
                        } else {
                            $echo .= '<td></td><td></td>';
                        }
                    }
                    //
                    if ($iswidget == '' && $change == 'true') {
开发者ID:par-orillonsoft,项目名称:creationOfSociety,代码行数:67,代码来源:cart-functions.php

示例4: number_format

       <?php 
    print $tax;
    ?>
% is $
       <?php 
    print number_format($total, 2);
    ?>
       </p>
<?php 
}
if (isset($_POST['submitted'])) {
    if (is_numeric($_POST['quantity']) && is_numeric($_POST['price'])) {
        if (is_numeric($_POST['tax'])) {
            calculate_total($_POST['quantity'], $_POST['price'], $_POST['tax']);
        } else {
            calculate_total($_POST['quantity'], $_POST['price']);
        }
    } else {
        echo '<h1>Error!</h1>';
        echo '<p class="error">Please enter a valid quantity and price.</p>';
    }
}
?>
   
   <h1>Widget cost calculator</h1>
   <form action="calculator.php" method="post">
       <p>Quantity: <input type="text" name="quantity" size="5" maxlength="5" 
          value="<?php 
if (isset($_POST['quantity'])) {
    echo $_POST['quantity'];
}
开发者ID:hamaenpaa,项目名称:own_code_examples,代码行数:31,代码来源:calculator.php

示例5: number_format

    // Turn 5% into .05.
    $total = $_POST['quantity'] * $_POST['price'] * ($taxrate + 1);
    $total = number_format($total, 2);
}
// End of function.
// Check if the form has been submitted.
if (isset($_POST['submitted'])) {
    if (is_numeric($_POST['quantity']) && is_numeric($_POST['price'])) {
        // Print the heading.
        echo '<h1 id="mainhead">总计:</h1>';
        $total = NULL;
        // Initialize $total.
        if (is_numeric($_POST['tax'])) {
            calculate_total($_POST['tax']);
        } else {
            calculate_total();
        }
        echo '<p>总计购买: ' . $_POST['quantity'] . ' 件商品,每件 ' . number_format($_POST['price'], 2) . ' 元,总价(含税)为 ' . $total . ' 元.</p>';
        // Print some spacing.
        echo '<p><br /></p>';
    } else {
        // Invalid submitted values.
        echo '<h1 id="mainhead">错误!</h1>
		<p class="error">请输入有效的商品数量及单价!</p><p><br /></p>';
    }
}
// End of main isset() IF.
// Leave the PHP section and create the HTML form.
?>
<h2>花费计算</h2>
<form action="calculator.php" method="post">
开发者ID:XINCGer,项目名称:phpWebTraining,代码行数:31,代码来源:calculator.php


注:本文中的calculate_total函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。