public function getSubTotal() { $price = Price::getFloat($this->getPricePaid()); $qty = $this->getQty(); $subtotal = $qty * $price; return $subtotal; }
public function submitPayment() { $dir = $this->getMethodDirectory(); require_once $dir . 'anet_php_sdk/AuthorizeNet.php'; $METHOD_TO_USE = "AIM"; define("AUTHORIZENET_API_LOGIN_ID", Config::get('vividstore.authnetLoginID')); // Add your API LOGIN ID define("AUTHORIZENET_TRANSACTION_KEY", Config::get('vividstore.authnetTransactionKey')); // Add your API transaction key define("AUTHORIZENET_SANDBOX", Config::get('vividstore.authnetTestmode')); // Set to false to test against production define("TEST_REQUEST", "FALSE"); // You may want to set to true if testing against production //define("AUTHORIZENET_MD5_SETTING",""); // Add your MD5 Setting. //$site_root = ""; // Add the URL to your site if (AUTHORIZENET_API_LOGIN_ID == "") { die('Enter your merchant credentials'); } $transaction = new AuthorizeNetAIM(); $transaction->setSandbox(AUTHORIZENET_SANDBOX); $transaction->setFields(array('amount' => Price::getFloat(VividCart::getTotal()), 'card_num' => $_POST['authnet-checkout-credit-card'], 'exp_date' => $_POST['authnet-checkout-exp-month'] . $_POST['authnet-checkout-exp-year'])); $response = $transaction->authorizeAndCapture(); if ($response->approved) { return true; } else { return array('error' => 1, 'errorMessage' => $response->error_message . " Error Code: " . $response->response_code . ". Message: " . $response->response_reason_text); } }
public function view() { $this->set("itemCount", StoreCart::getTotalItemsInCart()); $this->set("total", StorePrice::format(StoreCalculator::getSubTotal())); $js = \Concrete\Package\VividStore\Controller::returnHeaderJS(); $this->requireAsset('javascript', 'jquery'); $this->addFooterItem($js); $this->requireAsset('javascript', 'vivid-store'); $this->requireAsset('css', 'vivid-store'); }
public static function getTaxes($format = false) { $taxRates = self::getTaxRates(); $taxes = array(); if (count($taxRates) > 0) { foreach ($taxRates as $taxRate) { if ($taxRate->isTaxable()) { $taxAmount = $taxRate->calculate(); if ($taxAmount > 0) { $tax = true; } else { $tax = false; } if ($format == true) { $taxAmount = StorePrice::format($taxAmount); } $taxes[] = array('name' => $taxRate->getTaxLabel(), 'taxamount' => $taxAmount, 'based' => $taxRate->getTaxBasedOn(), 'taxed' => $tax); } } } return $taxes; }
public function add($data, $oID, $tax = 0, $taxIncluded = 0, $taxName = '') { $db = Database::get(); $product = VividProduct::getByID($data['product']['pID']); $productName = $product->getProductName(); $productPrice = Price::getFloat($product->getFormattedPrice()); $qty = $data['product']['qty']; $inStock = $product->getProductQty(); $newStock = $inStock - $qty; $product->setProductQty($newStock); $pID = $product->getProductID(); $values = array($oID, $pID, $productName, $productPrice, $tax, $taxIncluded, $taxName, $qty); $db->Execute("INSERT INTO VividStoreOrderItems (oID,pID,oiProductName,oiPricePaid,oiTax,oiTaxIncluded,oiTaxName,oiQty) VALUES (?,?,?,?,?,?,?,?)", $values); $oiID = $db->lastInsertId(); foreach ($data['productAttributes'] as $optionGroup => $selectedOption) { $optionGroupID = str_replace("pog", "", $optionGroup); $optionGroupName = VividProduct::getProductOptionGroupNameByID($optionGroupID); $optionValue = VividProduct::getProductOptionValueByID($selectedOption); $values = array($oiID, $optionGroupName, $optionValue); $db->Execute("INSERT INTO VividStoreOrderItemOptions (oiID,oioKey,oioValue) VALUES (?,?,?)", $values); } if ($product->hasDigitalDownload()) { $fileObjs = $product->getProductDownloadFileObjects(); $fileObj = $fileObjs[0]; $pk = \Concrete\Core\Permission\Key\FileKey::getByHandle('view_file'); $pk->setPermissionObject($fileObj); $pao = $pk->getPermissionAssignmentObject(); $u = new User(); $uID = $u->getUserID(); $ui = UserInfo::getByID($uID); $user = \Concrete\Core\Permission\Access\Entity\UserEntity::getOrCreate($ui); $pa = $pk->getPermissionAccessObject(); if ($pa) { $pa->addListItem($user); $pao->assignPermissionAccess($pa); } } }
public function getShippingTotal() { $smID = $_POST['smID']; echo StorePrice::format(StoreCalculator::getShippingTotal($smID)); }
public function view() { $this->set("itemCount", StoreCart::getTotalItemsInCart()); $this->set("total", StorePrice::format(StoreCalculator::getSubTotal())); }
public function calculateProduct($productObj, $qty) { if (is_object($productObj)) { if ($productObj->isTaxable()) { //if this tax rate is in the tax class associated with this product if ($productObj->getTaxClass()->taxClassContainsTaxRate($this)) { $taxCalc = $taxCalc = Config::get('vividstore.calculation'); if ($taxCalc == 'extract') { $taxrate = 10 / ($this->getTaxRate() + 100); } else { $taxrate = $this->getTaxRate() / 100; } switch ($this->getTaxBasedOn()) { case "subtotal": $productSubTotal = $productObj->getActivePrice() * $qty; $tax = $taxrate * $productSubTotal; $taxtotal = $taxtotal + $tax; break; case "grandtotal": $productSubTotal = $productObj->getActivePrice() * $qty; $shippingTotal = StorePrice::getFloat(StoreCalculator::getShippingTotal()); $taxableTotal = $productSubTotal + $shippingTotal; $tax = $taxrate * $taxableTotal; $taxtotal = $taxtotal + $tax; break; } } //if in products tax class } //if product is taxable } //if obj return $taxtotal; }
} //if cart ?> </ul> <?php if ($cart && !empty($cart)) { ?> <div class="cart-page-cart-total"> <span class="cart-grand-total-label"><?php echo t("Sub Total"); ?> :</span> <span class="cart-grand-total-value"><?php echo StorePrice::format($total); ?> </span> </div> <?php } else { ?> <p class="alert alert-info"><?php echo t('Your cart is empty'); ?> </p> <?php } ?>
</a> </div> <div class="checkout-cart-product-name"> <a href="<?php echo URL::page(Page::getByID($product->getProductPageID())); ?> "> <?php echo $product->getProductName(); ?> </a> </div> <div class="checkout-cart-item-price"> <?php echo Price::format($product->getActivePrice()); ?> </div> <?php if ($product->allowQuantity()) { ?> <div class="checkout-cart-product-qty"> <span class="checkout-cart-item-label"><?php echo t("Quantity:"); ?> </span> <?php echo $qty; ?> </div>
echo View::url('/dashboard/store/orders/order/', $order->getOrderID()); ?> "><?php echo $order->getOrderID(); ?> </a></td> <td><?php echo $order->getAttribute('billing_last_name') . ", " . $order->getAttribute('billing_first_name'); ?> </td> <td><?php echo $order->getOrderDate(); ?> </td> <td><?php echo Price::format($order->getTotal()); ?> </td> <td><?php echo ucwords($order->getStatus()); ?> </td> <td><a class="btn btn-primary" href="<?php echo View::url('/dashboard/store/orders/order/', $order->getOrderID()); ?> "><?php echo t("View"); ?> </a></td> </tr> <?php
//if is_object $i++; } //foreach } //if cart ?> </ul> <div class="cart-page-cart-total"> <span class="cart-grand-total-label"><?php echo t("Sub Total"); ?> :</span> <span class="cart-grand-total-value"><?php echo Price::format($total); ?> </span> </div> <div class="cart-page-cart-links"> <?php if ($cart && !empty($cart)) { ?> <a class="btn-cart-page-clear" href="javascript:vividStore.clearCart()"><?php echo t('Clear Cart'); ?> </a> <a class="btn-cart-page-checkout" href="<?php echo View::url('/checkout'); ?>
</thead> <tbody> <?php foreach ($products as $product) { ?> <tr> <td><?php echo $product['name']; ?> </td> <td><?php echo $product['quantity']; ?> </td> <td><?php echo Price::format($product['pricePaid']); ?> </td> </tr> <?php } ?> </tbody> </table> <?php if ($paginator->getTotalPages() > 1) { ?> <?php echo $pagination; }
public function getFormattedActivePrice() { return StorePrice::format($this->getActivePrice()); }
<td><?php echo Price::format($o->getShippingTotal()); ?> </td> <td> <?php $tax = $o->getTaxTotal(); $includedTax = $o->getIncludedTaxTotal(); if ($tax) { echo Price::format($tax); } elseif ($includedTax) { echo Price::format($includedTax); } ?> </td> <td><?php echo Price::format($o->getTotal()); ?> </td> </tr> <?php } ?> </tbody> </table> <?php if ($paginator->getTotalPages() > 1) { ?> <?php echo $pagination; }
$checked = true; } else { if ($i == 1) { $checked = true; } else { $checked = false; } } ?> <div class="radio"> <label> <input type="radio" name="shippingMethod" value="<?php echo $method->getShippingMethodID(); ?> "<?php if ($checked) { echo " checked"; } ?> > <?php echo $method->getName(); ?> - <?php echo StorePrice::format($method->getShippingMethodTypeMethod()->getRate()); ?> </label> </div> <?php $i++; }
public function getFormattedVariationPrice() { return StorePrice::format($this->pvPrice); }
public function getTotals() { $subTotal = Price::getFloat(Cart::getSubTotal()); $taxes = self::getTaxes(); $addedTaxTotal = 0; $includedTaxTotal = 0; if ($taxes) { foreach ($taxes as $tax) { if ($tax['calculation'] != 'extract') { $addedTaxTotal += $tax['taxamount']; } else { $includedTaxTotal += $tax['taxamount']; } } } $shippingTotal = Price::getFloat(Cart::getShippingTotal()); $total = $subTotal + $addedTaxTotal + $shippingTotal; return array('subTotal' => $subTotal, 'taxes' => $taxes, 'taxTotal' => $addedTaxTotal + $includedTaxTotal, 'shippingTotal' => $shippingTotal, 'total' => $total); }
public function view() { $this->set("itemCount", VividCart::getTotalItemsInCart()); $this->set("total", Price::format(VividCart::getSubTotal())); }
public function getTotal() { echo Price::format(VividCart::getTotal()); }
</a> </div> <div class="checkout-cart-product-name"> <a href="<?php echo URL::page(Page::getByID($product->getProductPageID())); ?> "> <?php echo $product->getProductName(); ?> </a> </div> <div class="checkout-cart-item-price"> <?php echo Price::format($product->getProductPrice()); ?> </div> <div class="checkout-cart-product-qty"> <span class="checkout-cart-item-label"><?php echo t("Quantity:"); ?> </span> <?php echo $qty; ?> </div> <?php if ($cartItem['productAttributes']) { ?>
public function getFormattedPrice() { return Price::format($this->pPrice); }
public function add($data, $pm, $status = null) { $taxBased = Config::get('vividstore.taxBased'); $taxlabel = Config::get('vividstore.taxName'); $this->set('taxlabel', $taxlabel); $taxCalc = Config::get('vividstore.calculation'); $db = Database::get(); //get who ordered it $customer = new Customer(); //what time is it? $dt = Core::make('helper/date'); $now = $dt->getLocalDateTime(); //get the price details $shipping = VividCart::getShippingTotal(); $shipping = Price::formatFloat($shipping); $taxvalue = VividCart::getTaxTotal(); $taxName = Config::get('vividstore.taxName'); $total = VividCart::getTotal(); $total = Price::formatFloat($total); $tax = 0; $taxIncluded = 0; if ($taxCalc == 'extract') { $taxIncluded = $taxvalue; } else { $tax = $taxvalue; } $tax = Price::formatFloat($tax); //get payment method $pmID = $pm->getPaymentMethodID(); //add the order $vals = array($customer->getUserID(), $now, $pmID, $shipping, $tax, $taxIncluded, $taxName, $total); $db->Execute("INSERT INTO VividStoreOrders(cID,oDate,pmID,oShippingTotal,oTax,oTaxIncluded,oTaxName,oTotal) VALUES (?,?,?,?,?,?,?,?)", $vals); $oID = $db->lastInsertId(); $order = Order::getByID($oID); if ($status) { $order->updateStatus($status); } else { $order->updateStatus(OrderStatus::getStartingStatus()->getHandle()); } $order->setAttribute("email", $customer->getEmail()); $order->setAttribute("billing_first_name", $customer->getValue("billing_first_name")); $order->setAttribute("billing_last_name", $customer->getValue("billing_last_name")); $order->setAttribute("billing_address", $customer->getValueArray("billing_address")); $order->setAttribute("billing_phone", $customer->getValue("billing_phone")); $order->setAttribute("shipping_first_name", $customer->getValue("shipping_first_name")); $order->setAttribute("shipping_last_name", $customer->getValue("shipping_last_name")); $order->setAttribute("shipping_address", $customer->getValueArray("shipping_address")); $customer->setLastOrderID($oID); //add the order items $cart = VividCart::getCart(); foreach ($cart as $cartItem) { $taxvalue = VividCart::getTaxProduct($cartItem['product']['pID']); $tax = 0; $taxIncluded = 0; if ($taxCalc == 'extract') { $taxIncluded = $taxvalue; } else { $tax = $taxvalue; } $productTaxName = $taxName; if ($taxvalue == 0) { $productTaxName = ''; } OrderItem::add($cartItem, $oID, $tax, $taxIncluded, $productTaxName); $product = VividProduct::getByID($cartItem['product']['pID']); if ($product && $product->hasUserGroups()) { $usergroupstoadd = $product->getProductUserGroups(); foreach ($usergroupstoadd as $id) { $g = Group::getByID($id); if ($g) { $customer->getUserInfo()->enterGroup($g); } } } } if (!$customer->isGuest()) { //add user to Store Customers group $group = \Group::getByName('Store Customer'); if (is_object($group) || $group->getGroupID() < 1) { $customer->getUserInfo()->enterGroup($group); } } // create order event and dispatch $event = new OrderEvent($order); Events::dispatch('on_vividstore_order', $event); //send out the alerts $mh = new MailService(); $pkg = Package::getByHandle('vivid_store'); $fromEmail = Config::get('vividstore.emailalerts'); if (!$fromEmail) { $fromEmail = "store@" . $_SERVER['SERVER_NAME']; } $alertEmails = explode(",", Config::get('vividstore.notificationemails')); $alertEmails = array_map('trim', $alertEmails); //receipt $mh->from($fromEmail); $mh->to($customer->getEmail()); $mh->addParameter("order", $order); $mh->addParameter("taxbased", $taxBased); $mh->addParameter("taxlabel", $taxlabel); $mh->load("order_receipt", "vivid_store"); $mh->sendMail(); //order notification $mh->from($fromEmail); foreach ($alertEmails as $alertEmail) { $mh->to($alertEmail); } $mh->addParameter("order", $order); $mh->addParameter("taxbased", $taxBased); $mh->addParameter("taxlabel", $taxlabel); $mh->load("new_order_notification", "vivid_store"); $mh->sendMail(); VividCart::clear(); return $order; }
public function getDisplay() { $display = trim($this->drDisplay); if ($display) { return $display; } else { if ($this->drDeductType == 'percentage') { return $this->drPercentage . ' ' . t('off'); } if ($this->drDeductType == 'value') { return StorePrice::format($this->drValue) . ' ' . t('off'); } } }
public function getShippingTotal() { $smID = $_POST['smID']; echo Price::format(VividCart::getShippingTotal($smID)); }