Example #1
0
/**
 * Create an actual order.
 *
 * @param array An array of information about the order.
 * @param array An array of items in the order.
 * @return string The token of the pending order.
 */
function CreateOrder($orderData, $orderProducts)
{
	$entity = new ISC_ENTITY_ORDER();

	// Delete the old configurable product files uploaded by the customers.
	DeleteOldConfigProductFiles();

	$pendingToken = GenerateOrderToken();
	$orderData['ordtoken'] = $pendingToken;
	$vendorInfo = $orderData['vendorinfo'];
	unset($orderData['vendorinfo']);
	foreach($vendorInfo as $vendorId => $vendorData) {
		$products = array();
		foreach($vendorData['products'] as $productId => $quantity) {
			$productInfo = $orderProducts[$productId];
			$productInfo['quantity'] = $quantity;
			$products[] = $productInfo;
		}
		list($vendorId,) = explode('_', $vendorId, 2);
		$vendorOrder = array_merge($orderData, $vendorData);
		$vendorOrder['products'] = $products;
		$vendorOrder['vendorid'] = $vendorId;
		// If we failed to add the order, stop
		if(!$entity->add($vendorOrder)) {
			return false;
		}
	}
	return $pendingToken;
}
Example #2
0
/**
 * Create an actual order.
 *
 * @param array An array of information about the order.
 * @param array An array of items in the order.
 * @return string The token of the pending order.
 */
function CreateOrder($orderData, $orderProducts)
{
    $entity = new ISC_ENTITY_ORDER();
    // Delete any orders that are incomplete and were placed more than a week ago. This helps keep the database clean
    $entity->DeleteOldOrders();
    // Delete the old configurable product files uploaded by the customers.
    DeleteOldConfigProductFiles();
    $pendingToken = GenerateOrderToken();
    $orderData['pending_token'] = $pendingToken;
    $vendorInfo = $orderData['vendorinfo'];
    unset($orderData['vendorinfo']);
    foreach ($vendorInfo as $vendorId => $vendorData) {
        $products = array();
        foreach ($vendorData['products'] as $productId => $quantity) {
            $productInfo = $orderProducts[$productId];
            $productInfo['quantity'] = $quantity;
            $products[] = $productInfo;
        }
        list($vendorId, ) = explode('_', $vendorId, 2);
        $vendorOrder = array_merge($orderData, $vendorData);
        $vendorOrder['products'] = $products;
        $vendorOrder['vendorid'] = $vendorId;
        // If we failed to add the order, stop
        //if(!$entity->add($vendorOrder)) {
        //return false;
        //}
        if ($_SESSION['makeaoffer'] == "Yes") {
            if (!$entity->offeradd($vendorOrder)) {
                return false;
            }
        } else {
            if (!$entity->add($vendorOrder)) {
                return false;
            }
        }
    }
    return $pendingToken;
}