![]() |
Subscription Status If/Then
Hi,
I've read ALL OVER the forum, (including: http://forum.x-cart.com/showthread.php?t=12511, http://forum.x-cart.com/showthread.php?t=8881, and http://forum.x-cart.com/showthread.php?t=46847) and I've seen many versions of if/then statements but I can't get them to work for what I need. All of the "if" membership statements are great but what would I code for a subscription status? For example, I have 3 subscription types: A, B, and C. I have a static page that is for current subscribers only that needs to show different content based upon the type of subscriber. Is there a way to tweak the following to be able to use it for subscription types instead of membership types: {if $user_membership eq '1'} Content for 1 {elseif $user_membership eq '2'} Content for 2 {else} sorry, membership needed for access. {/if} I've tried every version of subscriptionid, subscription, productid etc. Please help! Thanks in advance, Momtrepreneur X-cart Version 4.1.12 |
Re: Subscription Status If/Then
Using trial and error with the smarty variables can be frustrating. Why not use this tip so you can see exactly what smarty variables are available and their values? If variables for subscription are not available where you need them, you will have to update the corresponding php files. This thread describes a more convenient method to switch back and forth with the debug popup.
|
Re: Subscription Status If/Then
Thanks gb, that tip is neat. I was able to see lots of variables, but it seems like what I've found, I've used already! I must be inputting something wrong, missing a quote or period or something. Ugh! Please, if anyone can shed some light on this for me I would be very appreciative! In the meantime, I'm still trying different options.
|
Re: Subscription Status If/Then
Quote:
What is a "subscription" ? Is this a mod that you installed? Memberships. yes. But "subscriptions" -- where this set in xcart? |
Re: Subscription Status If/Then
Oh... no it came with my version 4.1.12. It's a module that you can activate by going to xcart > modules and selecting subscriptions. The membership feature would work for me, (and has as posted above) but memberships are not automated so I would have to manually check to make sure that the user had selected the correct membership. If I didn't catch it right away the user could have access to my protected content which are download links for my actual product. So, you can see my dilemma right?
|
Re: Subscription Status If/Then
I suspect that you are trying to do a simple if-then on variables that do not exist without a mod of the php file.
When you say you think you have the right variable - what variable would that be? Post the code with the variable you are using and we can check your syntax. Let me try and explain the tip provided a little better. The debug window that comes up displaying all the variables shows you everything that is available in smarty for that page. If it is not there - it is not available. You would see the variable for subscription that you seek and what it is set to. You would not need to try a bunch of different ones - you would see exactly what you expect. If it is not there, To make it available - you need to update the php to query the database to make the variables available to you. If you are not familiar with php or writing queries to get the information out of the database - this may be one for you to post in the professional requests forum, if you don't get response here. But you would need to be clearer in what you are doing to get better help. It is unclear what subscriptions you are referring to - product subscriptions? Newsletter subscriptions? A mod that you had done to your shop? For newsletter subscriptions - someone would have to be logged in. In the php - you would have to query the database to see if that person is subscribed to a newsletter, then set a variable in smarty to indicate which newslist, then you could do an if-than based on that variable. If the person is not logged in - you don't have a good way of knowing who they are. For purchased subscriptions - I am not very familiar, but it might be something like this: Again - they would need to be logged in. In the php, you would have to query the database to see if that person has purchased one of the subscriptions and set a variable, which you could use in smarty to do an if/than. |
Re: Subscription Status If/Then
Quote:
Ah... ok. I know zero about this module and the workings of it. You will need to be certain that the php is delivering the smarty variables to the page(s). That is beyond my expertise. At least we know where you need to start looking. Good luck. Jeremy |
Re: Subscription Status If/Then
Just so happens... someone else is asking about subscriptions... and it appears that few use this, and few know anything about it. Even Eugene, one of the masters from xcart, didn't have specifics. I would join this thread...
http://forum.x-cart.com/showthread.php?t=48321 |
Re: Subscription Status If/Then
Thanks you guys for the help!! I'm referring to the subscription module that comes with 4.1.12. It's not an extra mod I purchased or anything, it comes already installed. I use it for access to paid areas of my site. I have subscriber only (static) pages that need to be protected as well as my custom links on the product detail page that allow instant download to a subscriber. I've set the subscriptions up as a product ($productid) that renews on a scheduled basis.
Quote:
Quote:
Code:
In the debug window (from the tip) I saw variables like: Code:
I'm familiar with php and queries, but only when the code is already written, meaning I can understand and move it around once it exists. I don't know how to write a brand new query. Quote:
This is EXACTLY what I think is missing in order for the request above to work. However, I don't know how to do so. I've tried imitating some of the membership queries (tags, smarty code or whatever they're called) but have had no luck. Shouldn't there be something I can add to include/check_useraccount.php or another php or tpl file? Something like this? Code:
$subscription = $user_subscription['subscription']; Or something similiar? Thanks so much for the help, I really appreciate it. I'll keep trying. :? Momtrepreneur |
Re: Subscription Status If/Then
Hi again -
I suspect this mod will not be in the "easy" category - you're going to have to dig around. I'll help best I can - but remember - I am speculating a lot - I don't have experience with subscriptions. I also don't have time to run test cases and figure this out, so you will have to do the heavy lifting. If it looks too hairy - you can just write up exactly what you want accomplished and post to the Professional Help Services Request forum or to QT. First - I doubt there is an equivalent to the membership variable in the database for subscriptions. You can look in the tables in the database to see if something is there. Compare it to how membership id is handled. in the _customers table - you can see that every customer has an entry so you can see what membership id is associated with a customer. Look at the database for how information is stored for subscriptions. See how you can tell how to associate a particular subscription with a particular customer. Since a subscription is probably not like a membership - it is associated with a product and an order - which is then associated with a customer - you are going to have to understand how all this is organized in the db in order to write a query to get the information. Once you understand how it is organized - write a query that pulls the data that you need. Get the query working independent of XCART. You also have to consider in your query how you know the identity of the customer. I assume the customer has to be logged in. You will have to look through the php variables in XCART to see how this is done and use that in your query. Once your query is ready - figure out what pages in the cart you will want this data. Add your query to the php file associated with those pages. You can look at examples from other mods to see how people have added queries to the php files. Store the results of your query to a smarty variable or array. Now - the smarty variable is available to your template for your if/than statements. |
All times are GMT -8. The time now is 01:16 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.