liqiusheng / silverstripe-ecommerce

Automatically exported from code.google.com/p/silverstripe-ecommerce
0 stars 0 forks source link

[User Notice] Order is using alternative currency without exchange rate record. #544

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
e-commerce version: 3.1 13/08/2013

SilverStripe version: 3.1 from github

When click in copy (Account page)

[User Notice] Order is using alternative currency without exchange rate record.
GET /en-us/account/

Line 2288 in C:\wamp\www\ecommerce\code\model\Order.php
Source

2279     * Casted variable - has the order been submitted?
2280     * Currency is not the same as the standard one.
2281     * @return Boolean
2282     **/
2283    function HasAlternativeCurrency(){return 
$this->getHasAlternativeCurrency();}
2284    function getHasAlternativeCurrency() {
2285        if($currency = $this->CurrencyUsed()) {
2286            if(!$currency->IsDefault()) {
2287                if(!$this->ExchangeRate) {
2288                    user_error("Order is using alternative currency without exchange rate 
record.", E_USER_NOTICE);
2289                }
2290                return true;
2291            }
2292        }
2293        return false;
2294    }

Trace

    Order is using alternative currency without exchange rate record.
    Order.php:2288
    Order->getHasAlternativeCurrency()
    Order.php:2283
    Order->HasAlternativeCurrency()
    EcommerceCurrency.php:207
    EcommerceCurrency::get_money_object_from_order_currency(510.86,Order)
    Order.php:2004
    Order->getSubTotalAsMoney()
    Order.php:2002
    Order->SubTotalAsMoney()
    ViewableData.php:363
    ViewableData->obj(SubTotalAsMoney,,1,,)
    SSViewer.php:90
    SSViewer_Scope->getObj(SubTotalAsMoney,,1,,)
    SSViewer.php:493
    SSViewer_DataPresenter->getObj(SubTotalAsMoney,,1,,)
    SSViewer.php:110
    SSViewer_Scope->obj(SubTotalAsMoney,,1)
    .cache.ecommerce.templates.Includes.Sidebar_Cart_Inner.ss:29
    include(C:\wamp\www\silverstripe-cache\JOSE-PC\.cache.ecommerce.templates.Includes.Sidebar_Cart_Inner.ss)
    SSViewer.php:927
    SSViewer->includeGeneratedTemplate(C:\wamp\www/silverstripe-cache\JOSE-PC/.cache.ecommerce.templates.Includes.Sidebar_Cart_Inner.ss,Order,Array,Array,SSViewer_DataPresenter)
    SSViewer.php:994
    SSViewer->process(Order,Array,SSViewer_DataPresenter)
    SSViewer.php:1028
    SSViewer::execute_template(Sidebar_Cart_Inner,Order,Array,SSViewer_DataPresenter)
    .cache.ecommerce.templates.Includes.Sidebar_Cart.ss:19
    include(C:\wamp\www\silverstripe-cache\JOSE-PC\.cache.ecommerce.templates.Includes.Sidebar_Cart.ss)
    SSViewer.php:927
    SSViewer->includeGeneratedTemplate(C:\wamp\www/silverstripe-cache\JOSE-PC/.cache.ecommerce.templates.Includes.Sidebar_Cart.ss,AccountPage_Controller,Array,Array,SSViewer_DataPresenter)
    SSViewer.php:994
    SSViewer->process(AccountPage_Controller,Array,SSViewer_DataPresenter)
    SSViewer.php:1028
    SSViewer::execute_template(Sidebar_Cart,AccountPage_Controller,Array,SSViewer_DataPresenter)
    .cache.themes.senda.templates.Includes.SidebarRight.ss:18
    include(C:\wamp\www\silverstripe-cache\JOSE-PC\.cache.themes.senda.templates.Includes.SidebarRight.ss)
    SSViewer.php:927
    SSViewer->includeGeneratedTemplate(C:\wamp\www/silverstripe-cache\JOSE-PC/.cache.themes.senda.templates.Includes.SidebarRight.ss,AccountPage_Controller,Array,Array,SSViewer_DataPresenter)
    SSViewer.php:994
    SSViewer->process(AccountPage_Controller,Array,SSViewer_DataPresenter)
    SSViewer.php:1028
    SSViewer::execute_template(SidebarRight,AccountPage_Controller,Array,SSViewer_DataPresenter)
    .cache.senda_ecommerce.templates.Layout.AccountPage.ss:51
    include(C:\wamp\www\silverstripe-cache\JOSE-PC\.cache.senda_ecommerce.templates.Layout.AccountPage.ss)
    SSViewer.php:927
    SSViewer->includeGeneratedTemplate(C:\wamp\www/silverstripe-cache\JOSE-PC/.cache.senda_ecommerce.templates.Layout.AccountPage.ss,AccountPage_Controller,,Array,)
    SSViewer.php:994
    SSViewer->process(AccountPage_Controller,)
    SSViewer.php:990
    SSViewer->process(AccountPage_Controller)
    Controller.php:203
    Controller->handleAction(SS_HTTPRequest,index)
    RequestHandler.php:200
    RequestHandler->handleRequest(SS_HTTPRequest,DataModel)
    Controller.php:153
    Controller->handleRequest(SS_HTTPRequest,DataModel)
    ContentController.php:203
    ContentController->handleRequest(SS_HTTPRequest,DataModel)
    ModelAsController.php:68
    ModelAsController->handleRequest(SS_HTTPRequest,DataModel)
    Director.php:325
    Director::handleRequest(SS_HTTPRequest,Session,DataModel)
    Director.php:143
    Director::direct(/en-us/account/,DataModel)
    main.php:189

--------------------------------------

Regards,
Jose A.

Original issue reported on code.google.com by supp...@sendasoft.com on 14 Aug 2013 at 4:47

Attachments:

GoogleCodeExporter commented 8 years ago
I think I have fixed this... new code will be available in a few days. please 
reopen if it is not fixed in a few days. 

Original comment by nfranc...@gmail.com on 18 Aug 2013 at 9:44

GoogleCodeExporter commented 8 years ago
I think I have fixed this... new code will be available in a few days. please 
reopen if it is not fixed in a few days. 

Changed in shoppingcart:
$newOrder->CurrencyUsedID = $oldOrder->CurrencyUsedID;
TO:
//important to set it this way...
$newOrder->setCurrency($oldOrder->CurrencyUsedID);

Original comment by nfranc...@gmail.com on 18 Aug 2013 at 9:45

GoogleCodeExporter commented 8 years ago
Now produces the following error:

[Notice] Trying to get property of non-object
GET 
/shoppingcart/copyorder/878/?SecurityID=fef77d069d255d8a296cbae5927b25582e38cacb

Line 1164 in C:\wamp\www\ecommerce\code\model\Order.php
Source

1155     * Stores the preferred currency of the order.
1156     * IMPORTANTLY we store the exchange rate for future reference...
1157     * @param EcommerceCurrency $currency
1158     */
1159    public function UpdateCurrency($currency) {
1160        if($this->IsSubmitted()) {
1161            user_error("Can not set the exchange rate after the order has been 
submitted", E_USER_NOTICE);
1162        }
1163        else {
1164            $this->CurrencyUsedID = $currency->ID;
1165            $this->ExchangeRate = $currency->ExchangeRate();
1166            $this->write();
1167        }
1168    }
1169 
1170    /**

Trace

    Order->UpdateCurrency(3)
    Order.php:1174
    Order->SetCurrency(3)
    ShoppingCart.php:558
    ShoppingCart->copyOrder(Order)
    ShoppingCart.php:1363
    ShoppingCart_Controller->copyorder(SS_HTTPRequest)
    RequestHandler.php:288
    RequestHandler->handleAction(SS_HTTPRequest,copyorder)
    Controller.php:194
    Controller->handleAction(SS_HTTPRequest,copyorder)
    RequestHandler.php:200
    RequestHandler->handleRequest(SS_HTTPRequest,DataModel)
    Controller.php:153
    Controller->handleRequest(SS_HTTPRequest,DataModel)
    Director.php:325
    Director::handleRequest(SS_HTTPRequest,Session,DataModel)
    Director.php:143
    Director::direct(/shoppingcart/copyorder/878/,DataModel)
    main.php:189

Original comment by supp...@sendasoft.com on 20 Aug 2013 at 9:35

GoogleCodeExporter commented 8 years ago
I hope this is now fixed. 

Original comment by nfranc...@gmail.com on 21 Aug 2013 at 3:31