add default address for online shopping
authorKonrad Rosenbaum <konrad@silmor.de>
Tue, 20 Mar 2012 18:08:58 +0000 (19:08 +0100)
committerKonrad Rosenbaum <konrad@silmor.de>
Tue, 20 Mar 2012 18:08:58 +0000 (19:08 +0100)
www/inc/wext/customer.php
www/template/en/index.html

index cfe08f8..c411c61 100644 (file)
@@ -484,14 +484,24 @@ class WOCustomer extends WOCustomerAbstract
                }
                //store in cart
                if($storeincart){
+                       //get cart
                        $cartid=WebCart::getCart();
                        if($cartid==""){
                                $p=$twig->loadTemplate("carterror.html");
                                return $p->render($basevars);
                        }
+                       //get customer data
                        $cart=WTcart::getFromDB($cartid);
                        $cart->customerid=$ct->customerid;
                        $cart->update();
+                       //get address if there is none yet
+                       if($cart->deliveryaddress==false){
+                               $addrs=WTaddress::selectFromDB("customerid=".$ct->customerid,"ORDER BY lastused DESC");
+                               if(count($addrs)>0){
+                                       $cart->deliveryaddress=$addrs[0]->addressid;
+                                       $cart->update();
+                               }
+                       }
                }
                //store in session
                $sess=WOWebSession::getOrCreateWebSession();
index 95a058f..12ed001 100644 (file)
@@ -14,7 +14,7 @@
 <li><a href="{{script.tickets|raw}}">Ticket Shop</a></li>
 <li><a href="{{script.vouchers|raw}}">Voucher Shop</a></li>
 <li><a href="{{script.shop|raw}}">Merchandising</a></li>
-<li><a href="{{script.mycart|raw}}">My Shoping Cart</a></li>
+<li><a href="{{script.mycart|raw}}">My Shopping Cart</a></li>
 </ul>
 
 {% endblock page %}