Conditionally Show PO in Checkout
Posted: 13 December 2010 12:59 PM   Ignore ]  
Member
RankRankRank
Total Posts:  62
Joined  2010-11-09

I would like to conditional show the PO field on checkout based on a custom member field.  Maybe a checkbox that says PO terms (yes/no).  Foxy says that we can do that but I need to pass the variable via the JSON before they can help me with the code on their end.  How do I accomplish that?

UPDATEL:I looked through the Mod.foxee.php file and I notices the member_group_id is identified in the array.  I’m not sure how this works but if I can grab the group name from that ID and expose it in the JSON, then I can use that group ID/Name to conditionally show the PO field. 

The other option that I thought of was to pass the EE member group that the user belongs to and then show the PO field based on that.  I will also need it to work for the Unified Ordering, but since both of my options are by user or member group then I would think that this will not be an issue.  Am I correct in this assumption?

Profile
 
Posted: 15 December 2010 11:31 PM   Ignore ]   [ # 1 ]  
Administrator
Avatar
RankRankRankRank
Total Posts:  1654
Joined  2007-11-23

Im not sure but you can pass any information you want through the cart, then it sounds like Brett has an answer for you on how to code the checkout template to conditionally display the field.

Signature 

Mike

HCC Development

Profile
 
Posted: 16 December 2010 10:42 AM   Ignore ]   [ # 2 ]  
Member
RankRankRank
Total Posts:  62
Joined  2010-11-09

Hey Mike,

Here is his answer below, which I have tested in the console and it works.  I would just replace the product category with the json variable member group name.  I read up on the API from foxycart and I walked through the code in FoxEE and I can’t seem to find a place where I can “add” variables to the JSON. 

If a user is already logged into the site before they checkout, I assume the member group name can be brought over through the JSON object.  Frankly, after reading all the documentaion on both sites, I’m having trouble exposing the member group name in the JSON.  I walked myself throught the mod.foxee.php file and the FE_member_manager Class file but I’m not quite understanding how to show a specidfic field from EE and add to JSON. Can you point me in the right direction? 

If a user is not logged in and checkouts and URL goes off my subdomain from vltest.qnuru.com to qnuru.foxycart.com, then does FoxEE still talk back and forth with foxycart?  Can foxycart talk back to foxee once a user logs in on the checkout page?  So once you login on the checkout page (qnuru.foxycart.com) then the json object will fill for the member group name.  Your thoughts? 

jQuery(document).ready(function() {
var showPO false;
for (var 
i=0i<fc_json.products.lengthi++) {
if (fc_json.products [ i ] .category != "DEFAULT"{
showPO 
true;
}
}
if (!showPO{
jQuery
("#fc_payment_method_purchase_order_container").hide();
}
}
); 
Profile
 
Posted: 21 December 2010 11:12 AM   Ignore ]   [ # 3 ]  
Member
RankRankRank
Total Posts:  62
Joined  2010-11-09

Ok, So I’m using the addtocart_custom tag to pass the member id. 

{exp:foxee:addtocart_custom id="{entry_id}"}
        
<input type="hidden" name="member_group_id" value="{member_group}" />  
        <
input class="button" type="submit" name="submit" value="Add To Cart" />
{/exp:foxee:addtocart_custom} 

This passes the group ID to the json object.  If my user is logged into the site already this works, but if they aren’t and log in at checkout the ID isn’t updated because it is not part of the json object when you log in at checkout.  I need some guidance on how the SSO works so that i can get the member group id from EE using the SSO integration and update the json object or just use the variable passed by the SSO integration instead of updating the JSON object.  The documentation is vague on how to grab values or add information to the member integration.  I know the group ID is there because I can see it in the array in the code, but I just don’t know how to grab it.

Profile
 
Posted: 21 December 2010 05:11 PM   Ignore ]   [ # 4 ]  
Administrator
Avatar
RankRankRankRank
Total Posts:  1654
Joined  2007-11-23

the only way to pass a users member information to FoxyCart is to make sure they are logged in upon checkout. There is no way to back track after you reach the FC checkout form. If you are trying to use this process for “Guest” customers it will not work.

Signature 

Mike

HCC Development

Profile
 
Posted: 22 December 2010 11:53 AM   Ignore ]   [ # 5 ]  
Member
RankRankRank
Total Posts:  62
Joined  2010-11-09

Mike,

I can force them to login before checkout but my issue will lie within foxy’s Unified Ordering.  I want my customer service reps to log into someones account for them and place the order.  Is that possible if I force the user to log in prior to checkout?  I read in the documentation that FoxEE does not support Unified Ordering within EE yet.  Is the way I’m describing it correct in the assumption that FoxEE doesnt have that functionality?

Profile
 
Posted: 22 December 2010 04:11 PM   Ignore ]   [ # 6 ]  
Administrator
Avatar
RankRankRankRank
Total Posts:  1654
Joined  2007-11-23

You are correct, it does not. I do not understand what field you are trying to conditionally show but you may want to change the method. You could also have your admin log into the front end as the customer or make some sort of admin access template for unified orders. There is an option in the EE CP to log in as a user.

Signature 

Mike

HCC Development

Profile
 
Posted: 22 December 2010 04:20 PM   Ignore ]   [ # 7 ]  
Member
RankRankRank
Total Posts:  62
Joined  2010-11-09

Hey Mike,

There are 3 different payment types that Foxy handles.  Paypal, CC, and Purchase Order (PO).  A lot of our business is done in bulk for certain products so customers with PO Terms should be able to place an order and just put in the PO terms in the checkout.  No money exchanged over e-commerce.  In Foxy, you can either show the PO field for everyone or not show it for everyone.  Since not everyone has PO terms, I don’t want to show it to everyone cause then people can just place orders without paying. 

I’ll look into the EE CP to log in as a user, that sounds like it will solve the unified order problem on the FoxEE side.  Foxy wants me to develop a JSONP end point on the EE side that accepts an email address and sends back a group_member_id, this will allow me to keep the “guest” checkout feature.  I will start development but in the meantime I think I will see if I can get it to work using your solution above.  Thanks! 

Niraj

Profile
 
Posted: 23 December 2010 06:15 PM   Ignore ]   [ # 8 ]  
Member
RankRankRank
Total Posts:  62
Joined  2010-11-09

Hey Mike,

I decided to map a custom user field in EE to one of the fields I’m not using in foxy.  Working with foxy to finish the solution.  I’ll post the final solution here for all to see.

Niraj

Profile
 
Posted: 23 December 2010 07:41 PM   Ignore ]   [ # 9 ]  
Member
RankRankRank
Total Posts:  62
Joined  2010-11-09

Hey Mike,

So I mapped the shipping phone field from foxy to a custom profile field in EE on the user in the FoxEE settings.  Problem is that the information doesnt sync unless I log into the EE site first and then checkout.  If I checkout without logging in first and then login on the checkout form, the information doesn’t come into the form.  I plan to use that data to hide the PO field once I’m at foxy.  Is this standard functionality or is this a bug?

Profile
 
Posted: 27 December 2010 08:02 PM   Ignore ]   [ # 10 ]  
Administrator
Avatar
RankRankRankRank
Total Posts:  1654
Joined  2007-11-23

You won’t see any member data in the cart unless they are logged into EE first. FC does not look back to EE after logging in, it will only update EE after a successful purchase.

Signature 

Mike

HCC Development

Profile
 
Posted: 27 December 2010 09:24 PM   Ignore ]   [ # 11 ]  
Member
RankRankRank
Total Posts:  62
Joined  2010-11-09

Ok sounds good, is there an easy way to make the checkout button go to an EE login or register page prior to heading out to foxy?
UPDATE:  I am using the custom add to cart.  I want the custom add to cart submit button to go to review cart page that isn’t part of the foxy box.  Basically my own custom EE page where I just show the items in the cart.  Then I can simply do a conditional to send the user to either the checkout page on foxy or foxy cart depending on if they are logged in. 

Can I create an foxybox equivalent page in EE using FoxEE Tags?  I currently forward the form to a vew_cart page that has the item summary.  I can remove products but I can’t figure out how to update the quantity of the products like you can do in the foxy box.  Is this possible?  I want to bypass the foxybox altogether.

Profile
 
Posted: 28 December 2010 10:09 PM   Ignore ]   [ # 12 ]  
Member
RankRankRank
Total Posts:  62
Joined  2010-11-09

I came across another issue.  If I add a bunch of items to the cart, my hidden field in my custom add to cart tag won’t populate if I am not logged in.  I figured once I logged in the info in the JSON object would update.  But it doesn’t.  It only adds the info in the custom cart tag once you log in and then add items.  Is there a way to update the custom cart tag with the information in the hidden field after you log in?  I don’t want to force users to log in before they can start adding items to the cart. 

{assign_variable:purchase_order="{exp:member:custom_profile_data}{purchase_order}{/exp:member:custom_profile_data}"}
{exp
:foxee:addtocart_custom id="{entry_id}" block_foxybox="yes"}
         
<input type="hidden" name="h:purchase_order" value="{purchase_order}">  
         <
input type="hidden" name="redirect" value="index.php/products/view_cart"
<
input class="button" type="submit" name="submit" value="Add To Cart" /> 
Profile
 
Posted: 04 January 2011 10:40 AM   Ignore ]   [ # 13 ]  
Member
RankRankRank
Total Posts:  62
Joined  2010-11-09

This post is a resolution this thread that includes the setup and implementation of conditionally showing the Purchase Order field on checkout using FoxEE + FoxyCart.  This is the basic setup and it works pretty well if you are forcing users to login prior to going to foxycart for checkout and if you can live without having a shipping phone field (which I do not really have a need for).  I hope this helps others in setup. 

FoxEE Setup:
1. You must force the user to login on the EE side before you checkout.  You can accomplish this by using the custom add to cart foxEE tag and using a hidden input redirect to redirect the user to a EE custom login/checkout page.  Make sure to turn FoxyBox Off.  You can turn it on later once you force the user to login and/or if you want the ability to update quantity of the items in the cart.  I didn’t really have time to figure out how to update quantity using foxEE tags. 

2.  Create a custom profile field called purchase order under the members and groups section.  I use a straight text field and use either 0 or 1 in that field.  0 for false, 1 for true. 

3.  FoxEE Module—> General Settings—>  Click “Automatically Create and Map Member Fields”

4.  FoxEE Module—> General Settings —> Change the radio button for “Shipping Fields are the same?”  = “No”

5.  Map the shipping phone field to the purchase order field created in step 2.

6.  Go to the member and click on edit profile.  Set the member custom profile field.

FoxyCart Setup:
1.  Enable purchase order purchase in the payment settings
2.  Add the following code to the checkout template right above the </head> tag.  Add script tags around the below code. 

jQuery(document).ready(function() {
var purchase_order parseInt(jQuery('input[name=shipping_phone]').val());
window.alert( $('input[name=shipping_phone]').val());
if (
purchase_order == 0{
FC
.checkout.config.storeDetails.supportsPurchaseOrder false;
else {
FC
.checkout.config.storeDetails.supportsPurchaseOrder true;
}
}
); 

 
3.  Css hide the Shipping Phone Field using the CSS override documented on the foxycart site.

Profile
 
   
 
 

Join our Mailing List