oc-shopaholic / oc-orders-shopaholic-plugin

🛒 Orders (cart) extension for Shopaholic plugin
https://octobercms.com/plugin/lovata-ordersshopaholic
GNU General Public License v3.0
27 stars 18 forks source link

getTotalWeight method not working #192

Open euge001 opened 5 months ago

euge001 commented 5 months ago

getTotalWeight method (/var/www/html/ecommerce/plugins/lovata/ordersshopaholic/classes/collection/CartPositionCollection.php) not working same as many others in your very strangely designed application.

At /var/www/html/ecommerce/themes/lovata-shopaholic-sneakers/pages/checkout.htm made: function onStart() {
$this['path_page_js'] = mix('js/checkout.js', 'themes/lovata-shopaholic-sneakers/assets'); $this['path_page_css'] = mix('css/checkout.css', 'themes/lovata-shopaholic-sneakers/assets');

$obCartList = \Lovata\OrdersShopaholic\Classes\Collection\CartPositionCollection::make();
$this['totalWeight'] = $obCartList->getTotalWeight();

}

and in I alwayes get 0 whatever real value is.

kharanenka commented 5 months ago

Hello! CartPositionCollection::make() method creates empty collection. If you user onStart() function, that you can get full cart positions with using Cart component:

onStart()
{
     $obCartList = $this->Cart->get();
    $this['totalWeight'] = $obCartList->getTotalWeight();
}

"Cart" component gets cart_id from cookie and prepare list with cart positions