Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Showing some calculation at checkout
 
Reply
   X-Cart forums > X-Cart 5 > Modifying the design and features (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 09-09-2018, 02:11 PM
 
Daisy Daisy is offline
 

Member
  
Join Date: Aug 2010
Posts: 23
 

Question Showing some calculation at checkout

Hi there,
can somebody help me, I'm pretty stuck here


I tried to calculate processing time depending on items in cart and orders in status 'P' so I created a mod that extends cart class like this:


Code:
namespace XLite\Module\Dsy\ProcessingTime\View; /** * Cart widget * */ abstract class Cart extends \XLite\View\Cart implements \XLite\Base\IDecorator { /** * Returns Processing Time * * @return string */ public function getProcessingTime() { $items = $this->getCart()->countQuantity(); $time = ceil($items/5); $orders = \XLite\Core\Database::getRepo('XLite\Model\Order') ->createQueryBuilder('o') ->andWhere('o.shippingStatus = :id') ->setParameter('id', '2') ->getResult(); $openorders = count($orders); if ( $openorders > 0 ) { $openorders = floor($openorders / 3); } $time = $time + $openorders; return $time; } }


This works fine on cart page, where I added a twig like this:


theme_tweaker\customer\shopping_cart\parts\process ingtime.twig


Code:
{## # Shopping cart items block # # @ListChild (list="cart.children", weight="30") # @ListChild (list="checkout.cart", weight="30") #} <div class="subtotal" style="text-align: right; padding-top: 45px;"> <strong>{{ t('Expected delivery time in working days') }}: {{ this.getProcessingTime() }}</strong> </div>


It shows up beneath subtotal, you can see in screenshot 1.


Then I wanted to add the same to FastLaneCheckout right beneath shipping methods so that customers can combine delivery time with processing time.


theme_tweaker\customer\modules\XC\FastLaneCheckout \sections\shipping\processingtime.twig


Code:
{## # Fastlane checkout processing time # # @ListChild (list="checkout_fastlane.sections.shipping.right", weight="20") #} <div class="subtotal" style="text-align: right; padding-top: 45px;"> <strong>{{ t('Expected delivery time in working days') }}: {{ this.cart.getProcessingTime() }}</strong> </div>


I had to add .cart before getProcessingTime(), otherwise I got this error



Quote:
XLite [error] Trying to call undefined class method; class - "XLite\Controller\Customer\Checkout", function - "getProcessingTime"


But with this.cart.getProcessingTime() the error disappears and the page is shown correctly but the value of this.cart.getProcessingTime() is missing. (screenshot 2).


The function is there, but it won't return anything. I added var_dump at the beginning so I found out it won't even get called.


I'v been trying for hours and days. I tried different things: various listviews on that page, extending other classes like controller\customer\checkout and so on, but nothing. What am I missing?



I just learned about x-cart 5 file structure and twig templates, adding modules and redefining classes. I didn't read the whole developer manuals so I think it's just something real stupid that I did wrong. Do you have any suggestions?



Best regards,
Daisy
Attached Thumbnails
Click image for larger version

Name:	screenshot 1.png
Views:	3
Size:	11.0 KB
ID:	5226  Click image for larger version

Name:	screenshot 2.png
Views:	2
Size:	11.8 KB
ID:	5227  
__________________
X-Cart Version 4.7.9 => 5.3.5
Reply With Quote
  #2  
Old 09-12-2018, 01:00 PM
 
Daisy Daisy is offline
 

Member
  
Join Date: Aug 2010
Posts: 23
 

Default Re: Showing some calculation at checkout

done... found the correct viewer class to use and solved error in redefinition
__________________
X-Cart Version 4.7.9 => 5.3.5
Reply With Quote

The following user thanks Daisy for this useful post:
qualiteam (09-13-2018)
Reply
   X-Cart forums > X-Cart 5 > Modifying the design and features (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 09:52 AM.

   

 
X-Cart forums © 2001-2018