implement place order
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Mon, 7 Feb 2011 20:11:59 +0000 (20:11 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Mon, 7 Feb 2011 20:11:59 +0000 (20:11 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@721 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

wob/classes/cart.wolf
www/inc/rendering/cart_listing.php
www/template/en/placeorder.html [new file with mode: 0644]

index 6553e48..0c47b0a 100644 (file)
                <Property name="tickets" type="List:CartTicket"/>
                <Property name="vouchers" type="List:CartVoucher"/>
                <Property name="items" type="List:CartItem"/>
+               
+               <Mapping table="cart">
+                       <Map property="customerid"/>
+                       <Map property="deliveryaddressid" column="deliveryaddress"/>
+                       <Map property="invoiceaddressid" column="invoiceaddress"/>
+                       <Map property="comment"/>
+                       <Map property="shippingtypeid" column="shippingtype"/>
+                       <Map property="tickets">
+                               <Call lang="php" method="WOCartTicket::fromTableArraycartticket(WTcartticket::selectFromDB('cartid='.$GLOBALS['db']->escapeString($table->cartid)))"/>
+                       </Map>
+                       <Map property="vouchers">
+                               <Call lang="php" method="WOCartVoucher::fromTableArraycartvoucher(WTcartvoucher::selectFromDB('cartid='.$GLOBALS['db']->escapeString($table->cartid)))"/>
+                       </Map>
+                       <Map property="items">
+                               <Call lang="php" method="WOCartItem::fromTableArraycartitem(WTcartitem::selectFromDB('cartid='.$GLOBALS['db']->escapeString($table->cartid)))"/>
+                       </Map>
+               </Mapping>
        </Class>
        
        <Class name="WebCart">
index 74b5784..f3b58c0 100644 (file)
@@ -398,7 +398,26 @@ static public function changeAddressPage($mode)
 
 static public function placeOrder()
 {
-       die ("not implemented");
+       global $basevars,$twig,$db;
+       //get cart object
+       $cartid=self::getCart();
+       if($cartid==""){
+               return $twig->loadTemplate("carterror.html")->render($basevars);
+       }
+       $cart=WOCartOrder::fromTablecart(WTcart::getFromDB($cartid));
+       if(!is_a($cart,"WOCartOrder")){
+               return $twig->loadTemplate("carterror.html")->render($basevars);
+       }
+       //push it to order
+       $trans=WTrCreateOrder::execute($cart,false);
+       //delete cart
+       $where="cartid = ".$db->escapeString($cartid);
+       $db->deleteRows("cartticket",$where);
+       $db->deleteRows("cartvoucher",$where);
+       $db->deleteRows("cartitem",$where);
+       $db->deleteRows("cart",$where);
+       //go home
+       return $twig->loadTemplate("placeorder.html")->render($basevars);
 }
 
 //end of WebCart
diff --git a/www/template/en/placeorder.html b/www/template/en/placeorder.html
new file mode 100644 (file)
index 0000000..f8705a4
--- /dev/null
@@ -0,0 +1,16 @@
+{# Example Template for MagicSmoke
+   ================================
+   this one is called after an order has been placed successfully
+#}
+
+{% extends 'layout.html' %}
+
+{% block title %}Order Placed{% endblock %}
+
+{% block page %}
+
+Your order has been placed. You will receive confirmation via email.<p/>
+
+<a href="{{script.root}}">Continue shopping</a><p/>
+
+{% endblock %}