Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Smarty Variables On Checkout Complete Rate Topic   * * * * * 1 votes

 
  • tzifman
  • Newbie
  • Members
  • Join Date: 23-Apr 14
  • 11 posts

Posted 07 June 2016 - 10:55 AM #1

Hello 

 

I try to write code for a loop on checkout complete. My code at the moment is: 

 

<script>
test("setCurrency", "978");
 
{foreach from=$order_info.products item="product" key="key"}
test("addItem", {
id: "{$product.product_id}"
,price: {math equation="x / y" x=$product.price y=1.24 format="%.2f"}
,quantity: "{$product.amount}"
,payout: "1"
,category: "{$product.main_category.category_id}"
});
 
{/foreach}
</script>
 
1. Product ID is ok.
2. Price is ok.
3. Quantity is ok
4. Category isnt ok. I need to show category id of each product but i cant. Any idea? 
5. Payout istnt ok. I need to show number based on category ID.
 
 
Any help is more than welcome 
 
Thanks


 
  • abolshakov
  • Architect
  • CS-Cart Architects
  • Join Date: 20-Aug 14
  • 93 posts

Posted 07 June 2016 - 11:03 AM #2

What do you mean by "ok" and "not ok"? Can you please post here raw output of your code?


Alexander Bolshakov
CS-Cart Architect Team


 
  • tzifman
  • Newbie
  • Members
  • Join Date: 23-Apr 14
  • 11 posts

Posted 07 June 2016 - 11:14 AM #3

ok means that is ok and i dont need to change anything.

 

Here is output: 

 

 
test("addItem", {
id: "63544"
,price: "40.22"
,quantity: "1"
,category: ""
,payout: "1"
});
 
test("addItem", {
id: "58856"
,price: "0.63"
,quantity: "6"
,category: ""
,payout: "1"
});


 
  • abolshakov
  • Architect
  • CS-Cart Architects
  • Join Date: 20-Aug 14
  • 93 posts

Posted 07 June 2016 - 11:18 AM #4

Consider dumping the contents of $product variable in the foreach cycle: {$product|fn_print_r}, so you'll be able to view its internal structure.


Alexander Bolshakov
CS-Cart Architect Team


 
  • tzifman
  • Newbie
  • Members
  • Join Date: 23-Apr 14
  • 11 posts

Posted 07 June 2016 - 11:29 AM #5

Already did this but hasnt info that i need: 

 

[item_id] =&gt; 3001273677
[order_id] =&gt; 67068
[product_id] =&gt; 63544
[product_code] =&gt; V32517
[price] =&gt; 40.22
[amount] =&gt; 1
[extra] =&gt; Array
(
[product_options] =&gt; Array
(
)
[unlimited_download] =&gt; N
[no_installments_nbgdatacash] =&gt; N
[no_installments] =&gt; N
[product] =&gt; Canon Pixma iP2850 Color Inkjet Printer 8745B006AA
[company_id] =&gt; 1
[is_edp] =&gt; N
[edp_shipping] =&gt; N
[discount] =&gt; 0
[base_price] =&gt; 40.22
[stored_price] =&gt; N
)
[product] =&gt; Canon Pixma iP2850 Color Inkjet Printer 8745B006AA
[product_status] =&gt; A
[deleted_product] =&gt; 
[discount] =&gt; 0
[company_id] =&gt; 1
[base_price] =&gt; 40.22
[original_price] =&gt; 40.22
[cart_id] =&gt; 3001273677
[tax_value] =&gt; 0
[subtotal] =&gt; 40.22
[display_subtotal] =&gt; 40.22
[shipped_amount] =&gt; 0
[shipment_amount] =&gt; 1
[is_accessible] =&gt; 1
[shared_product] =&gt; 1


 
  • tzifman
  • Newbie
  • Members
  • Join Date: 23-Apr 14
  • 11 posts

Posted 07 June 2016 - 12:25 PM #6

Update: 

 

Price is ok with this smarty: 

 

price: {math equation="x / y" x=$product.price y=1.24 format="%.2f"}



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19959 posts

Posted 07 June 2016 - 02:11 PM #7

Try to use:

{$_pdata = $product.product_id|fn_get_product_data:$auth}
....
category: "{$_pdata.main_category|fn_get_category_name}"

Not sure what do you mean by payout


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • tzifman
  • Newbie
  • Members
  • Join Date: 23-Apr 14
  • 11 posts

Posted 07 June 2016 - 02:33 PM #8

ecom thanks 

 

i can see now category name but not id. 



 
  • abolshakov
  • Architect
  • CS-Cart Architects
  • Join Date: 20-Aug 14
  • 93 posts

Posted 07 June 2016 - 02:34 PM #9

Category ID is in $_pdata.main_category


Alexander Bolshakov
CS-Cart Architect Team


 
  • tzifman
  • Newbie
  • Members
  • Join Date: 23-Apr 14
  • 11 posts

Posted 07 June 2016 - 02:39 PM #10

i tried this: 

 

category: "{$_pdata.main_category.category_id}"

 

but doesnt work



 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1249 posts

Posted 08 June 2016 - 05:09 AM #11

Please try
 

...
,category:"{$_pdata.main_category}"
...


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19959 posts

Posted 08 June 2016 - 07:16 AM #12

The final code should be:

{$_pdata = $product.product_id|fn_get_product_data:$auth}
....
category: "{$_pdata.main_category}"

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)