Jump to content

Licensecart


Michael

Recommended Posts

  • 3 weeks later...

Hey,

Why don't you pick a template on Themeforest and cusstomize it?

 

http://themes.truethemes.net/Sterling-HTML/page-template-homepage-jquery.html

But there are a lot more and you can customize the colors, too.

not sure I'd rather learn the gist of Bootstrap and do it myself and that way it's not a cheap layout anyone can buy.

Link to comment
Share on other sites

  • 2 weeks later...

Ah yeah that's because you've visited for the first time, it's calling the prices from the API.

 

You shouldn't be calling prices from the API on every single pageload that displays prices.

 

And it doesn't work like that, it's not a "first time" thing - its every page load, because every single time you load a page that calls the prices, you're calling the API.  It doesn't cache those unless you set it up to do so.

 

I do understand that you're trying to be fancy and all, but how much time do you really save by having the pricing automatically updated on your website?

Link to comment
Share on other sites

What do you mean it is a require_once?

 

That still requires it every page refresh, require_once just makes sure that it only includes the file once in a single page, not for every refresh.

 

http://php.net/manual/en/function.require-once.php

 

It looks nice, it just loads pretty slowly.

I don't understand what you mean by having it so it's only included on a single page? 

 

Code we got given by Devs: http://staging.blesta.com/forums/index.php?/topic/592-display-prices-on-your-website/

 

If you don't include it how will it connect to the api to get the prices by setting cookies? air?

Link to comment
Share on other sites

I don't understand what you mean by having it so it's only included on a single page? 

 

Code we got given by Devs: http://staging.blesta.com/forums/index.php?/topic/592-display-prices-on-your-website/

 

If you don't include it how will it connect to the api to get the prices by setting cookies? air?

 

You seem to think that by using 'require_once' it won't need to keep including it after a refresh when it does..

 

With the script in that post you linked, using just 'require' instead of 'require_once' would do exactly the same thing.

 

No need to act childish with sarcasm, when I'm just trying to state a point.

Link to comment
Share on other sites

You seem to think that by using 'require_once' it won't need to keep including it after a refresh when it does..

 

With the script in that post you linked, using just 'require' instead of 'require_once' would do exactly the same thing.

 

No need to act childish with sarcasm, when I'm just trying to state a point.

None of them is as you call it cache it for the next person.

Link to comment
Share on other sites

Well, while not necessarily the best option, you can definitely use cookies. Load the API on the first visit, then set a cookie with the DISPLAY prices. Caution: Don't use that price when calculating at checkout! But yeah, get the prices once, set a cookie for like 24 hours, then use the cookie data on all the other page loads.

 

Basically set up the code that gets the price from the API and creates the cookie in a function called something like getPriceFor($item) then you can do something like:

 

$price1 = ( empty( $_COOKIE['item1Price'] ) ) ? getPriceFor('item1') : $_COOKIE['item1Price'];

 

 

That way, it only hits the API once every so often to update the cookie. You could then use a quick code to force a cookie refresh when/if the prices change later... Just thinking out loud :)

 

---- 

 

Definitely make sure you fight things like cross site scripting too if you go this route...

Link to comment
Share on other sites

I would cache it to disk. serialized array written to a file, read the data from the file instead.. then, randomly on page load make another API call and overwrite the file. 1% of page loads should be enough.

 

This would be the best option, caching it to a file in php is the easiest way, would only take a few minutes to implement, shouldn't use cookies when you don't need to.

Link to comment
Share on other sites

I would cache it to disk. serialized array written to a file, read the data from the file instead.. then, randomly on page load make another API call and overwrite the file. 1% of page loads should be enough.

 

I've never heard of that before? is that like the call to home you have got for blesta?

Link to comment
Share on other sites

I've never heard of that before? is that like the call to home you have got for blesta?

 

No, it has nothing to do with licensing. It's just a common way to do caching. There's no need to make slower API calls for every page load when the data isn't changed frequently. This is more similar to what w3tc does for Wordpress.

Link to comment
Share on other sites

I've used something like this before; http://codecanyon.net/item/php-simple-cache/4169137

 

It basically saves the page as a HTML page and you can set how long that cache lasts, after that it will read and save the page again over the last one.

 

Therefore it won't call the API every reload, it will just read what was on the page at the time of the cache, you can set the expire from anywhere between an hour, or a month.

Link to comment
Share on other sites

I've used something like this before; http://codecanyon.net/item/php-simple-cache/4169137

 

It basically saves the page as a HTML page and you can set how long that cache lasts, after that it will read and save the page again over the last one.

 

Therefore it won't call the API every reload, it will just read what was on the page at the time of the cache, you can set the expire from anywhere between an hour, or a month.

:o wicked :D thank you.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...