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

Best way to query variables in 5.3

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 01-23-2018, 05:38 PM
 
BurtonTech BurtonTech is offline
 

Advanced Member
  
Join Date: Aug 2007
Posts: 46
 

Default Best way to query variables in 5.3

Hello,

I have a tracking code for the homepage and the receipt page that needs the order total and order number if they exist. What's the best way to get these values in a 5.3.x twig file?

Thanks!
__________________
X-Cart Gold 4.4.5
X-Cart Ultimate 5.2.22
X-Cart Business 5.3.2.13
X-Payments 3
Reply With Quote
  #2  
Old 01-24-2018, 02:36 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Best way to query variables in 5.3

It depends on the twig file. For each twig template there is a PHP "widget" class that retrieves data and provides methods for the template to read it. If there is no method in the widget class, the template will look for a method in the controller class.

What twig file you want to show the data? Is it a custom one? If so, how did you add it to the home page?
And what is the data?
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #3  
Old 01-24-2018, 10:43 AM
 
BurtonTech BurtonTech is offline
 

Advanced Member
  
Join Date: Aug 2007
Posts: 46
 

Default Re: Best way to query variables in 5.3

I'm planning on putting an affiliate tracking code in a footer twig file since we may need to modify it to show up on other pages in the near future. It will only ever need to be present on the product, category, home, and checkoutSuccess pages. For now I'll use this.getTarget() as a selector. This twig file seems to work well for that:

customer/layout/footer/main.footer.section.twig

The data that we need to query is the current order number and subtotal amount of the cart. I'm not sure at what point the order number is generated, but we can just pass a blank value until it is generated.

Is there a widget call or global variable I can call to pull this data?

Thanks!
__________________
X-Cart Gold 4.4.5
X-Cart Ultimate 5.2.22
X-Cart Business 5.3.2.13
X-Payments 3
Reply With Quote
  #4  
Old 01-27-2018, 10:23 AM
 
BurtonTech BurtonTech is offline
 

Advanced Member
  
Join Date: Aug 2007
Posts: 46
 

Default Re: Best way to query variables in 5.3

So spending about 5 seconds on Google shows me how to get cart totals in mode widely adopted shopping carts.

Magento:
Code:
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $cart = $objectManager->get('\Magento\Checkout\Model\Cart'); $subTotal = $cart->getQuote()->getSubtotal(); $grandTotal = $cart->getQuote()->getGrandTotal();

or Woocommerce:
Code:
WC()->cart->get_cart_total();

But apparently to grab common order or cart data in the X-Cart, the calls vary from twig to twig file? I couldn't find any documentation or community support covering it, so my only options are to painfully reverse engineer even the most trivial tasks? Or is there an object that allows me to pull out variable data from whatever twig file I want to display it?

Any direction is greatly appreciated!
__________________
X-Cart Gold 4.4.5
X-Cart Ultimate 5.2.22
X-Cart Business 5.3.2.13
X-Payments 3
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (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 11:17 PM.

   

 
X-Cart forums © 2001-2020