Ejemplo n.º 1
0
<?php

$html = '';
if (is_array($checkout) && !empty($checkout)) {
    $html .= '<div class="checkout" data-checkout-forms>
              <div data-checkout-total><h1>' . Text_Helper::format_string_as_price($checkout['cart_total']) . '</h1></div>
              <form data-ajax-form data-action="submit_coupon">
                <div data-form-msg></div>
                ' . implode('', $checkout['types']) . '
                <ul class="inline">
                  <li><input type="text" name="coupon_code" value="" /></li>
                  <li class="submit"><button type="submit"  class="btn btn-primary">Add Coupon</button></li>
                </ul>
              </form>

              <form data-ajax-form data-action="submit_order">

                <label>Credit Card #:</label>
                <ul>
                  <div data-form-msg></div>
                  <li><input type="text" name="fake_cc" value="" /></li>
                  <input type="hidden" name="order_total" data-order-total value="' . $checkout['cart_total'] . '" />
                  <li class="submit"><button type="submit" class="btn btn-primary btn-huge">Submit Order!</button></li>
                </ul>
                ' . implode('', $checkout['products']) . '
              </form>
            </div>';
}
echo $html;
Ejemplo n.º 2
0
<?php

$html = $ingredients = '';
if (is_array($cart_item) && !empty($cart_item)) {
    if (is_array($cart_item['product_ingredients']) && !empty($cart_item['product_ingredients'])) {
        foreach ($cart_item['product_ingredients'] as $ingredient) {
            $type = new Ingredient_Type($ingredient->ingredient_type);
            $ingredients .= '<li>' . $type->ingredient_type_name . ' - ' . $ingredient->ingredient_name . '</li>';
        }
    }
    $html .= '<li class="cart-item">
              <span>' . Text_Helper::format_string_as_price($cart_item['product_price_total']) . '</span>
              <h2>' . $cart_item['product_type'] . '</h2>
              <ul>' . $ingredients . '</ul>
            </li>';
}
echo $html;
Ejemplo n.º 3
0
<?php

require_once '../../functions.php';
$data = $_POST;
$resp = new Ajax_Response($data['action'], true);
if (is_array($data) && !empty($data)) {
    $order_total = $data['order_total'];
    $user = new User($_SESSION['current_user']);
    $cart = new Cart($user->user_id);
    $order = new Order();
    $order_id = $order->create_order_record($user, $order_total);
    if (is_int($order_id)) {
        $result = $order->create_order_product_records($order_id, $data['cart_product']);
        if ($result) {
            //$cart->destroy_cart( $user );
            $resp->set_status(true);
            $resp->set_message('Thanks for buying ' . count($data['cart_product']) . ' items for ' . Text_Helper::format_string_as_price($data['order_total']) . ' ');
        } else {
            $resp->set_message('Could not create order product records. Whoops');
        }
    } else {
        $resp->set_message('Could not create order record. Try again.');
    }
} else {
    $resp->set_message('Could not process Order. Sorry.');
}
echo $resp->encode_response();
die;
Ejemplo n.º 4
0
<?php

require_once '../../functions.php';
session_start();
$data = $_POST;
$resp = new Ajax_Response($data['action'], true);
if (is_array($data) && !empty($data)) {
    $coupon_code = htmlspecialchars(trim($data['coupon_code']));
    $user = new User($_SESSION['current_user']);
    $cart = new Cart($user->user_id);
    $coupon = new Coupon($coupon_code);
    if ($coupon->coupon_id != null) {
        $total = $cart->get_cart_total();
        $discounted_total = (double) $total - (double) $coupon->coupon_discount;
        $resp->set_status(true);
        $resp->set_data(array('discount_total' => $discounted_total, 'original_total' => $total, 'discount_html' => '<h1>' . Text_Helper::format_string_as_price($discounted_total) . '</h1>
                                                <small>' . Text_Helper::format_string_as_price($coupon->coupon_discount) . ' off</small>'));
        $resp->set_message(ucfirst($coupon_code) . ' successfully applied!');
    } else {
        $resp->set_message(ucfirst($coupon_code) . ' is not a valid coupon. Sorry.');
    }
} else {
    $resp->set_message('No Coupon code received. Try Again.');
}
echo $resp->encode_response();
die;