make more data available for placing order page
authorKonrad Rosenbaum <Konrad.Rosenbaum@peergroup.com>
Sat, 26 Sep 2015 20:58:43 +0000 (22:58 +0200)
committerKonrad Rosenbaum <Konrad.Rosenbaum@peergroup.com>
Sat, 26 Sep 2015 20:58:43 +0000 (22:58 +0200)
www/inc/rendering/cart_listing.php
www/template/en/layout.html
www/template/en/placeorder.html

index b6a2772..e2126f3 100644 (file)
@@ -409,15 +409,27 @@ static public function placeOrder()
        if(!is_a($cart,"WOCartOrder")){
                return $twig->loadTemplate("carterror.html")->render($basevars);
        }
+       //get the web-object
+    $wcart = WOWebCart::fromTablecart(WTcart::getFromDB($cartid));
+    if(!is_a($wcart,"WOWebCart")){
+        //ooops. internal problem
+        $p=$twig->loadTemplate("carterror.html");
+        return $p->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);
+       if($trans->resultorder()!==false){
+        $where="cartid = ".$db->escapeString($cartid);
+        $db->deleteRows("cartticket",$where);
+        $db->deleteRows("cartvoucher",$where);
+        $db->deleteRows("cartitem",$where);
+        $db->deleteRows("cart",$where);
+    }
        //go home
+       $basevars['incart']=$wcart;
+    $basevars['order']=$trans->resultorder();
+    $basevars['outcart']=$trans->resultcart();
        return $twig->loadTemplate("placeorder.html")->render($basevars);
 }
 
@@ -427,4 +439,4 @@ static public function placeOrder()
 
 //eof
 return;
-?>
\ No newline at end of file
+?>
index 6918383..9f03af6 100644 (file)
@@ -20,7 +20,7 @@
 {% endfor %}
 {% endif %}
 <br/>
-<div style="font-size:50%">Session: {{sessionid}}</div>
+<div style="font-size:50%">Session: {{sessionid}}; Welcome to MagicSmoke {{user.title}} {{user.name}} ({{user.email}})</div>
 </p>
 <!-- End Menu -->
 
index f8705a4..ad8acfc 100644 (file)
@@ -13,4 +13,215 @@ Your order has been placed. You will receive confirmation via email.<p/>
 
 <a href="{{script.root}}">Continue shopping</a><p/>
 
+<hr/>
+
+{# ######################################################################
+    CART
+####################################################################### #}
+
+
+ <h2>Customer</h2>
+ {{incart.customer.title}} {{incart.customer.name}}, {{incart.customer.firstname}}
+ <h3>Invoice Address</h3>
+ {% if incart.invoiceaddress|isObject %}
+ {{incart.invoiceaddress.name}}<br/>
+ {{incart.invoiceaddress.addr1}}<br/>
+ {{incart.invoiceaddress.addr2}}<br/>
+ {{incart.invoiceaddress.zipcode}} {{incart.invoiceaddress.city}}, {{incart.invoiceaddress.state}}<br/>
+ {{incart.invoiceaddress.country.name}}
+ {% else %}
+ No invoice address.
+ {% endif %}
+ <h3>Delivery Address</h3>
+ {% if incart.deliveryaddress|isObject %}
+ {{incart.deliveryaddress.name}}<br/>
+ {{incart.deliveryaddress.addr1}}<br/>
+ {{incart.deliveryaddress.addr2}}<br/>
+ {{incart.deliveryaddress.zipcode}} {{incart.deliveryaddress.city}}, {{incart.deliveryaddress.state}}<br/>
+ {{incart.deliveryaddress.country.name}}
+ {% else %}
+ Same as invoice address.
+ {% endif %}
+
+ <h2>Cart Items</h2>
+ {# build a table with all the items of this shopping cart:
+ this is the headline: #}
+ <table frame="1" border="1">
+ <tr><td><b>Item</b></td><td><b>Item Price</b></td><td><b>Amount</b></td><td><b>Sum</b></td></tr>
+ {# go through tickets and render them #}
+ {% for ticket in incart.tickets %}
+   {% set pricesum=ticket.price * ticket.amount %}
+   <tr>
+   <td>Ticket: {{ticket.event.title}} ({{ticket.eventprice.pricecategory.name}})</td>
+   <td align="right">{{ticket.price|asMoney}}</td>
+   <td align="right">{{ticket.amount}}</td>
+   <td align="right">{{pricesum|asMoney}}</td>
+   </tr>
+ {% endfor %}
+ {# now go through vouchers #}
+ {% for voucher in incart.vouchers %}
+ <tr>
+ <td>Voucher</td>
+ <td align="right">{{voucher.value|asMoney}}</td>
+ <td align="right">1</td>
+ <td align="right">{{voucher.value|asMoney}}</td>
+ </tr>
+ {% endfor %}
+ {# TODO: go through product items #}
+ {# render the shipping option #}
+ {% if incart.shipping|isObject %}
+   <tr><td>Shipping: {{incart.shipping.description}}</td>
+   <td align="right">{{incart.shipping.cost|asMoney}}</td>
+   <td align="right">1</td>
+   <td align="right">{{incart.shipping.cost|asMoney}}</td></tr>
+ {% else %}
+   <tr><td colspan="3">No Shipping</td><td align="right">{{0|asMoney}}</td></tr>
+ {% endif %}
+
+ {# the overall sum of the above items... #}
+ <tr><td colspan="3" align="right"><b>Sum:</b></td><td><b>{{incart.totalsum|asMoney}}</b></td></tr>
+ {# end of the table #}
+ </table>
+
+<hr/>
+{# ######################################################################
+    ORDER
+####################################################################### #}
+
+{% if order|isObject %}
+<h1>Order No. {{order.orderid}}</h1>
+
+<h2>Customer</h2>
+ {{order.customer.title}} {{order.customer.name}}, {{order.customer.firstname}}
+ <h3>Invoice Address</h3>
+ {% if order.invoiceaddress|isObject %}
+ {{order.invoiceaddress.name}}<br/>
+ {{order.invoiceaddress.addr1}}<br/>
+ {{order.invoiceaddress.addr2}}<br/>
+ {{order.invoiceaddress.zipcode}} {{order.invoiceaddress.city}}, {{order.invoiceaddress.state}}<br/>
+ {{order.invoiceaddress.country.name}}
+ {% else %}
+ No invoice address.
+ {% endif %}
+ <h3>Delivery Address</h3>
+ {% if order.deliveryaddress|isObject %}
+ {{order.deliveryaddress.name}}<br/>
+ {{order.deliveryaddress.addr1}}<br/>
+ {{order.deliveryaddress.addr2}}<br/>
+ {{order.deliveryaddress.zipcode}} {{order.deliveryaddress.city}}, {{order.deliveryaddress.state}}<br/>
+ {{order.deliveryaddress.country.name}}
+ {% else %}
+ Same as invoice address.
+ {% endif %}
+
+ <h2>Cart Items</h2>
+ {# build a table with all the items of this shopping cart:
+ this is the headline: #}
+ <table frame="1" border="1">
+ <tr><td><b>ID</b></td><td><b>Item</b></td><td><b>Item Price</b></td></tr>
+ {# go through tickets and render them #}
+ {% for ticket in order.tickets %}
+   <tr>
+   <td>Ticket: {{ticket.ticketid}}</td>
+   <td>{{ticket.event.title}} ({{ticket.pricecategory.name}})</td>
+   <td align="right">{{ticket.price|asMoney}}</td>
+   </tr>
+ {% endfor %}
+ {# now go through vouchers #}
+ {% for voucher in order.vouchers %}
+ <tr>
+ <td colspan="2">Voucher: {{voucher.voucherid}}</td>
+ <td align="right">{{voucher.value|asMoney}}</td>
+ </tr>
+ {% endfor %}
+ {# TODO: go through product items #}
+ {# render the shipping option #}
+ {% if order.shippingtype|isObject %}
+   <tr><td colspan="2">Shipping: {{order.shippingtype.description}}</td>
+   <td align="right">{{order.shippingcosts|asMoney}}</td></tr>
+ {% else %}
+   <tr><td colspan="2">No Shipping</td><td align="right">{{0|asMoney}}</td></tr>
+ {% endif %}
+
+ {# the overall sum of the above items... #}
+ <tr><td colspan="2" align="right"><b>Sum:</b></td><td><b>{{order.totalprice|asMoney}}</b></td></tr>
+ {# end of the table #}
+ </table>
+
+{% else %}
+ARRRRGGHHHHHH!
+{% endif %}
+
+<hr/>
+
+{# ######################################################################
+    Problem-Cart
+####################################################################### #}
+
+{% if outcart|isObject %}
+
+ <h2>Cart Items</h2>
+ {# build a table with all the items of this shopping cart:
+ this is the headline: #}
+ <table frame="1" border="1">
+ <tr><td><b>Item</b></td><td><b>Item Price</b></td><td><b>Amount</b></td><td><b>Sum</b></td></tr>
+ {# go through tickets and render them #}
+ {% for ticket in outcart.tickets %}
+   {% set pricesum=ticket.price * ticket.amount %}
+   <tr>
+   <td>Ticket: {{ticket.event.title}} ({{ticket.eventprice.pricecategory.name}})</td>
+   <td align="right">{{ticket.price|asMoney}}</td>
+   <td align="right">{{ticket.amount}}</td>
+   <td align="right">{{pricesum|asMoney}}</td>
+   <td>{{ticket.str_status}}</td>
+   </tr>
+ {% endfor %}
+ {# now go through vouchers #}
+ {% for voucher in incart.vouchers %}
+ <tr>
+ <td>Voucher</td>
+ <td align="right">{{voucher.value|asMoney}}</td>
+ <td align="right">1</td>
+ <td align="right">{{voucher.value|asMoney}}</td>
+ <td>{{voucher.str_status}}</td>
+ </tr>
+ {% endfor %}
+ {# TODO: go through product items #}
+ {# end of the table #}
+ </table>
+
+
+{% endif %}
+
+
+{# ######################################################################
+    End of Page
+####################################################################### #}
+
 {% endblock %}
+