How to output time remaining in days or hours with liquid? - shopify

I'm selling shirts on my website, and I want to add a countdown timer to the page to show how long left customers have to pre-order the shirts (only taking orders until a specified date when I'll manually shut off ordering from the Shopify backend).
I'd like to know if there is a way to accomplish outputting just the correct days/hours remaining to markup via some math operation (or other built-in function) in liquid? I'd prefer not to use a javascript based solution because I want a load of this operation to be on the server, not the front-end.
My end goal is to end up with something rendered that looks like this:
<p>You have <strong>14 days</strong> left to pre-order.</p>
...where the content inside the <strong> tags is generated by the function and shows days only until the last 24 hours when it would show hours remaining.
Is this possible with liquid? Would accomplishing with javascript actually be a better choice?
Site for reference: http://devtees.com/

It’s not that it isn’t possible in liquid due to syntax reasons, but I don’t believe that the variables you’re looking for exist in Shopify.
You’d probably need to create a custom variable (a 'metafield') for the deadline date, in which case you wouldn’t be able to filter it using liquid’s date filters (because the liquid doesn’t know it’s a date — it just sees it as a string). So you wouldn’t be able to affect the formatting, count down, etc.
Learn more about metafilters: http://docs.shopify.com/themes/liquid-documentation/objects/metafield
An alternative approach might be to leverage some combination of a metafield specifying the “last day to order” and toggling of the product’s availability. With that method, you could achieve something similar to the way Cotton Bureau shows the pre-orderability of their t-shirts.
Learn more about product availability: http://docs.shopify.com/themes/liquid-documentation/objects/product#product-available

Related

Shopify variable price for a single product

I am about to display a rack builder in my shopify.
The users can set various customization like the number of rows and columns and the size of each cell and its door option for each cell.
The problem is that I would like to know how to enable variable price for that product. I think I cant use variant product as it will be limited in number.
This will require quite a lot of customisation.
First you will need to split your rack elements into separate products:
doors
rows
columns
sizes
You will need to enter variants for each of the different elements.
Once you are done with that you will need to create a page that allows you to customise the product showing the options from the product elements you created above.
You will need to collect the product customisation with JS and add the appropriate amount of each element to the cart.
In case the customer have the option of manual input and the price is changed based on that ( for example the size of the wood ) then the functionality will become even more complex.
Long story short it will be hard to code, the administration will be complex and the user experience won't be nice.
Another way will be to look into some APP that can help you with this, but I'm not sure if there is one that has this kind of functionality.

Subscription capability

We have a series of products that are subscription based. ie: first 7 days free, then a monthly or annual fee with a start date and finish date. Is this possible ? and could we drive this through the REST API ?
Moving my comment to answer -
I would like to second #KimballRobinson's comments. It might be possible. The REST API by itself gives you access to store data. You can create products and maintain them. In your case, things to consider - what is the product taxonomy like and can it be defined as custom fields or something of that sort. Maybe you can set it up in a way such that you charge/invoice the customer for the same product every month or annually. There are ways in which you can implement subscription. If you define details more on the scope of what you are trying to accomplish, it will be easier to figure out

Venue History Pagination

How are we supposed to paginate through the venuehistory (https://developer.foursquare.com/docs/users/venuehistory) endpoint? In the docs, it mentions two parameters, beforeTimestamp and afterTimestamp, but the result set contains no reference timestamp points to paginate from. Am I missing something?
Background
I'm testing currently testing on an account with 22 items, so perhaps the pagination hasn't kicked in yet, but it would still be nice to cover this scenario. Thanks!
/users/venuehistory returns the user's whole venuehistory, so typically you do not need to paginate it. The beforeTimestamp and afterTimestamp are used if you want to only show history from a certain time period (such as only showing check-ins in January, for a calendar view of check-ins).

How to decide whether to split up a VB.Net application and, if so, how to split it up?

I have 2 1/2 years experience of VB.Net, mostly self taught, so please bear with me if I seem rather noobish still and do not know some of the basics. I would recommend you grab a cup of tea before starting on this, as it appears to have got quite long...
I currently have a rather large application (VB.Net website) of over 15000 lines of code at the last count. It does not do retail or anything particularly complex like that - it is literally just a wholesale viewing website with admin frontend, catalogue / catalogue management system and pageview system.
I don't really know much about how .Net applications work in the background - whether they are all loaded on the same thread or if each has its own thread... I just know how to code them, or at least like to think I do... :-)
Basically my application is set up as follows:
There are two different areas - the customer area and the administration frontend.
The main part of the customer frontend is the Catalogue. The MasterPage will load a list of products but that's all, and this is common to all the customer frontend pages.
I tend to work on only one or several parts of the application at a time before uploading the changes. So, for example, I may alter the hierarchy of the Catalogue and change the Catalogue page to match the hierarchy change whilst leaving everything else alone.
The pageview database is getting really quite large and so it is getting rather slow when the application is first requested due to the way it works.
The application timeout is set to 5 minutes - don't know how to change it, I have even tried asking this question on here and seem to remember the solution was quite complex and I was recommended not to change it, but if a customer requests the application 5 minutes after the last page view then it will reload the application from scratch. This means there is a very slow page load whenever it exceeds 5 minutes of inactivity.
I am not sure if this needs consideration to determine how best to split the application up, if at all, but each part of the catalogue system is set up as follows:
A Manager class at the top level, which is used by the admin frontend to add, edit and remove items of the specified type and the customer frontend to retrieve a list of items of the specified type. For example the "RangeManager" will contain a list of product "Ranges" and will be used to interact with these from the customer frontend.
An Item class, for example Range, which contains a list of Attributes. For example Name, Description, Visible, Created, CreatedBy and so on. The form for adding / editing loops through these to display relevant controls for the administrator. For example a Checkbox for BooleanAttribute.
An Attribute class, which can be of type StringAttribute, BooleanAttribute, IntegerAttribute and so on. There are also custom Attributes (not just datatypes) such as RangeAttribute, UserAttribute and so on. These are given a data field which is used to get a piece of data specific to the item it is contained in when it is first requested. Basically the Item is given a DataRow which is stored and accessed by Attributes only when they are first requested.
When one item is requested from a specific manager is requested, the manager will loop through all the items in the database and create a new instance of the item class. For example when a Range is requested from the RangeManager, the RangeManager will loop through all of the DataRows in the Ranges table and create a new instance of Range for each one. As stated above it simply creates a new instance with the DataRow, rather than loading all the data into it there and then. The Attributes themselves fetch the relevant data from the DataRow as and when they're first requested.
It just seems a tad stupid, in my mind, to recompile and upload the entire application every time I fix a minor bug or a spelling mistake for a word which is in the code behind (for example if I set the text of a Label dynamically). A fix / change to the Catalogue page, the way it is now, may mean a customer trying to view the Contact page, which is in no way related to the Catalogue page apart from by having the same MasterPage, cannot do so because the DLL is being uploaded.
Basically my question is, given my current situation, how would people suggest I change the architecture of the application by way of splitting it into multiple applications? I mean would it be just customer / admin, or customer / admin and pageviews, or some other way? Or not at all? Are there any other alternatives which I have not mentioned here? Could web services come in handy here? Like split the catalogue itself into a different application and just have the masterpage for all the other pages use a web service to get the names of the products to list on the left hand side? Am I just way WAY over-complicating things? Judging by the length of this question I probably am, and it wouldn't be the first time... I have tried to keep it short, but I always fail... :-)
Many thanks in advance, and sorry if I have just totally confused you!
Regards,
Richard
15000 LOC is not really all that big.
It sounds like you are not pre-compiling your site for publishing. You may want to read this: http://msdn.microsoft.com/en-us/library/1y1404zt(v=vs.80).aspx
Recompiling and uploading the application is the best way to do it. If all you are changing is your markup, that can be uploaded individually (e.g. changing some html layout in an aspx page).
I don't know what you mean here by application timeout, but if your app domain recycles every 5 minutes, then that doesn't seem right at all. You should look into this.
Also, if you find yourself working on various different parts of the site (i.e. many different changes), but need to deploy only some items in isolation, then you should look into how you are using your source control tools (you are using one, aren't you?). Look into something like GIT and branching/merging.
Start by reading:
Application Architecture Guide

Some undesired words appeared in Google's snippets, how to get read of it?

I know Google's creation of sites' titles and descriptions (or "snippets") are mainly come from META description. However, when one of my web pages shows up, there are some undesired words like price (which is not good at all). What I want it to show is just the description of the product rather than its price. Actually the price only mentioned twice in the whole page.
How could this happen? And how can I remedy it?
Including the price in the snippet is actually very desirable for most people. If your price is higher than the competition's for the same products they probably don't want to buy from you and check out other results instead.
To make sure the search engines don't see the price (and thus don't display it in the results) you should use JavaScript. I think even Amazon does this to prevent screen scraping in some cases. It should be easy, especially with something like jQuery.
$('#priceForProduct987A').html("$125")
You should be able to control the snippet displayed by google through the use of the meta tags:
http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=79812
However the results displayed by Google in this case might be different if someone is trying to do some searching on a product. Google will then think you're shopping for that product and try to display the price of it. This might be the case for you.