How to get the customer’s LightSpeed Webstore minicart to show in WordPress Theme

For ages I’ve known how to get WordPress stuff to show up in my Webstores. But getting Webstore stuff to show up in my WordPress themes seemed to be beyond me.
I’d tried and tried and given up many times. So today when working on a client project I don’t know what made me try again. I just felt like I knew more now than I did and this time I might be able to do it. And I did it. Amazing.

Enough with the chitter chatter here is how I did it.

Went to (where webstore is installed), opened index.php and found this: require_once(‘includes/prepend.inc.php’);.

Then I made a copy of my_webstore_location/templates/my_template/minicart.tpl.php.

And in my WordPress theme I created a new file called “webstore-minicart.php”.

In webstore-minicart.php I pasted the contents of minicart.tpl.php.

And webstore-minicart.php, after the first < ?php, I pasted require_once('/path/to/webstore_location/includes/prepend.inc.php'); The path to file prepend.inc.php is very important. It has to be 100% correct or you'll get a nasty error or just a white page. You don't want that. If you don't know the server path to your webstore location ( where your webstore files are) here's the easiest way to find it out: create a file named info.php in the same directory where your shop is installed. If it's in /shop place info.php in /shop. In info.php paste: [php] <?php phpinfo();?>[/php] Then load the file in your browser by going to www.your-domain.com/shop/info.php Find PHP Variables and locate _SERVER["SCRIPT_FILENAME"] everything before the actual name of the file is the server path to the file. On one server the path to the file could be /home/user/username/htdocs - just for example. On another server it could be /blah/blahbla/public_html. In any case if you load info.php you ought to be able to find it out. Note: PHP errors will include the path so if you get the path wrong pay attention to any errors that occur. Whew. So now that we know where the file is and how to tell PHP where to find it we can display the minicart in our WordPress theme! [php] <?php get_template_part('webstore-minicart');?> [/php] Unfortunately, I have had to be secretive when it comes to customizing LightSpeed Webstore because there are very large multiple person team companies that do the same work as I do and charge a lot more than I do and get more customers than I do but never ever share their code! So I'm not going to post webstore-minicart.php for you on this site but if you contact me and ask me for it I will send it to you.

LightSpeed Webstore: a way to have product images larger than 512×512

Let’s face it, as a web designer it’s not fun to have to tell a client that they can’t have something and if they’re using LightSpeed Web Store for their eCommerce solution ( developed by that venerable company, LightSpeed) they can’t have all the bells and whistles for their product images.

On the client’s side, the LightSpeed POS looks so flashy and so well, capable that they’re often flummoxed when they’re told they can’t have product images larger than 512 pixels, width/height. Make sure right off the bat you pony up that wobbler: 512 x 512 is the max photo size. But keep it a secret if you like explaining big caveats seconds before the launch.

“What’s all this fuss about. I sell products that sell themselves. My customers couldn’t care less about photos.” Really? What kind of products don’t even need a photo? The product photo is the only way to show customers… Wait, you do know we are talking about online stores, right?

“What’s all this fuss about. I only use the POS and couldn’t give less of a hoot.” Why are you talking to me, then?

“What’s all this fuss about. 512 x 512 is plenty big. In fact, if the photos were any larger customers would be able to see how bad my photographs are. Couldn’t have that. Might have to actually pay an actual photographer one day but for now my smartphone’s camera and I do the job. And it’s free.”

Do not get me started on cutting corners with product photography. Besides, just because other webstore owners could have larger images wouldn’t mean you’d have to also have larger images.You could keep uploading little photos.

All joking aside, while it’s not that important to brick & mortar retailers ( for obvious reasons I really hope), it’s very important, if not vital for online resellers to have larger product images. If I shop online I won’t buy an apparel product unless I can see a larger image of it. This goes for shoes, handbags, hats and jewelry. I suspect if covers furniture, art and table-top as well as bath appointments and fixtures and what ever else kinds of products where you have to be able to see the product enlarged in order to feel confident enough about it in order to add it to your cart.

What we can do with the template, right now, out of the box:
If we have the real estate and the desired look allows for it we can enlarge the product detail images area to accomodate a full size 512 x 512 image. But most of the time we don’t have that much space to work with.

But say we can squeeze the full-size in, then what?
If we’re restricted to just 512 w/h, we can’t use a zoom tool because we’d be zooming a 512 image and what we’d get is ugly not to mention useless because you’re supposed to zoom to a larger image than what is already visible not show the exact same image size in a lightbox window.

The “solution” that’s most widely used is to make the main image display at a smaller width/height so that the lightbox window actually shows a larger image… with well-shot additional images that close up on important details, it can work.

But if you can use it WordPress can fill in where LightSpeed leaves off.

First of all, I’m not suggesting you should install WordPress if all you’re going to be using it for is to have larger images. But WordPress makes it so damn easy to upload images, create posts and insert images in these posts and get the webstore template to show the posts in a lightbox/fancybox window that it wouldn’t be so nuts if you did install WordPress just for Larger Product Images. Not everyone uses an FTP client. At least,my clients certainly don’t. So if you go for “ease of use” over how much it’s going to be used I don’t think anyone would blame you. That much.

I registered a custom post type named Larger Product Images in my theme’s functions.php.
When I made my larger image posts I used a Featured Image and I inserted 2 to 3 inline images into the post editor.
As far as creating the single template went, the images inserted into the editor were the_content();.
The Featured Image, the_post_thumbnail(‘larger-image’); was declared in functions.php with add_image_size( ‘larger-image’, 600, 600 );.

I added a new template file to my theme called single-{name-of-post-type}.php. Since I wasn’t really concerned with the way the permalinks looked and I wanted a really, really unique post type name, I’d named my post type “lgr-imgs-gal” which meant my single template was named single-lgr-imgs-gal.php. Again you don’t have to be that precious about setting up the post type. You could do something as slight as this (in functions.php of your WordPress theme):

[php]// register custom post type

function register_custom_post_types() {
// register custom post type
$labels = array(
‘name’ => ‘Product Larger Image Galleries’,
‘singular_name’ => ‘Product Larger Image Gallery’
);

$args = array(
‘labels’ => $labels,
‘public’ => true,
‘capability_type’ => ‘post’,
‘exclude_from_search’ => true,
‘supports’ => array(‘title’,’editor’,’thumbnail’,’custom-fields’),
);

register_post_type(‘lgr-imgs-gal’, $args);
}

add_action(‘init’, ‘register_custom_post_types’);
[/php]

This post type doesn’t need an archive and the URLs don’t have to make any sense human-readable-wise. All it’s doing is showing larger images in the webstore. Also, the theme never has to call the file in the WordPress part of the site, meaning you aren’t going to be showing the larger image galleries in a custom page or anything like that. As far as visitors looking through your site are concerned this post type doesn’t exist except to show larger images in the webstore via a “simple” link (placed somewhere logical in product_details.php).

The “simple” link:
[php]<a class="fooey view" href="http://www.your-domain.com/your-wordpress-location/lgr-imgs-gal/<?= strtolower(preg_replace(‘/[^A-Za-z0-9-]/’, ”,$this->prod->Name));?>/"><?php _xt("Larger Images");?></a>[/php]

Most of the URL is hard coded because it can be. The part that can’t be hardcoded is the name of the product so we have to use code to get that. Luckily that’s included in the template file for us. The new code will take all the spaces and make the product name all lowercase. This should make linking to the single galleries by name easier.

To create the titles of the posts all you have to do is hover over the link that the code above creates. Go to your webstore, click through to a single product and hover over the link text – you’ll see what the revised name of the product is. Use the revised name as the Title of the larger image gallery Post.

You can even copy the link and paste it into the Title area of the Post Editor and delete everything up to the actual name if you’re still not sure what it is.

If you want to be more careful about things ( say you have 2 products with the same name for some reason but they have different product codes) you could put the product code in the URL and use that as the post title.
Just replace $this->prod->Name with $this->prod->Code. We went with names because it seemed easier to understand. If your product codes are strictly numerical you don’t even need the part of the code that removes the spaces and makes it all lowercase ( since all lowercase only applies to alphabetical characters). In that case you could probably get by with just this:

[php]<a class="fooey view" href="http://www.your-domain.com/your-wordpress-location/lgr-imgs-gal/<?= $this->prod->Code));?>/"><?php _xt("Larger Images");?></a>[/php]

Where your webstore is installed, locate assets/js/webstore.js.
If you haven’t edited this file you should be able to locate lines 42 to 46:

[php]$(document).ready(function()
{
$("#xlsSearch").bind(‘keyup’,autosuggest);
$("a.iframe").fancybox();
});
[/php]

Right after:

$("a.iframe").fancybox();

Paste this:

[php]$(‘a.fooey.view’).fancybox({
‘width’: ‘100%’,
‘height’: ‘100%’,
‘type’: ‘ajax’,
‘ajax’: {
dataFilter: function(data) {
return $(data).find(‘#largesse’)[0];
}
}

});

$("#thumbs a").live(‘click’, function(evt) {

evt.preventDefault();

$("#main-image").empty().append(

$("<img>", {
src: this.href
}
));
});
[/php]

All the above does is make the link load the single galleries in a lightbox-ish window using fancybox which is a jquery plugin that is loaded with webstore by default. *Meaning I didn’t add it, they did so it’s approved to be used in webstore.

*About that little comment:
Whenever possible I try to avoid adding new stuff to webstore because every so often my clients have an issue with the Point of Sale & webstore and the 1st thing they hear is “well, your template is custom, must be a problem with the code in it”. Sometimes this is true. But since I’ve gotten very very very careful when making custom webstores it’s not as true as it used to be :).

In fact you should never mention your webstore is custom when contacting support. Not to be mendacious ( anyway they’re going to look at your store in a browser and see it’s customized) but to stop the support thread from stopping at “well, it’s customized”. If you EVER contact support about something in the webstore not working be sure to tell them that you recreated the issue you’re having with a completely clean webstore. That means the template was switched FROM the Custom template To Deluxe, Basic or Framework and each of these templates are 100% unedited and virgin. It also means removing any other edits you made to any other file anywhere else. And for the sake of everybody’s sanity please actually do this, don’t just say you did it! That’s not fair to support and you won’t get to the bottom of the issue (probably). The whole point of this advice is to make sure they talk to you about the actual issue not about the fact that you webstore isn’t using Deluxe, Basic or Framework.

What about single-lgr-imgs-gal.php?
Won’t the lightbox window load a complete page when we only need to get the galleries not the whole page?
Here is the template:

[php]<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( ‘charset’ ); ?>" />
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<title><?php

global $page, $paged;
wp_title( ‘|’, true, ‘right’ );

?></title>

<link rel="stylesheet" type="text/css" href="<?php bloginfo( ‘stylesheet_directory’ ); ?>/larger-image.css" />
</head>

<body class="single-lgr-imgs-gal">

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>

<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

<div id="largesse" class="larger-images-entry larger-images">
<div id="thumbs"><?php the_content(); ?></div>
<div id="main-image"><?php the_post_thumbnail(‘larger-image’);?>
</div>
</div><!– .entry-content –>

<div class="entry-utility">
<?php edit_post_link( __( ‘Edit’, ‘coclico’ ), ‘<span class="edit-link">’, ‘</span>’ ); ?>
</div><!– .entry-utility –>
</div><!– #post-## –>

<?php endwhile; // end of the loop. ?>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$("#thumbs a").live(‘click’, function(evt) {
evt.preventDefault();
$("#main-image").empty().append(
$("<img>", { src: this.href}));

});

});

</script>

</body>
</html>
[/php]
The code in webstore.js is only going to load div#largesse in the fancybox window.

Everything else such as normal document structure,css and javascript (to make the thumbnails in the gallery load into div#main-image stage) is so that the galleries – if they get loaded outside the fancybox – will work and look nice.
You’ll still have to add the css for the galleries into webstore/yourtemplate/css/webstore.css.

Anyway I hope this helps someone out. I beat my brains out doing it but I’m glad I did it because it works really well.

One last thing: make sure to use http://mydomain.com OR http://www.mydomain.com, not both. So go to WordPress > dashboard > Settings > General and check the wordpress address and the site address. They should be either http://mydomain.com/ OR http://www.mydomain.com. It seems to make a difference with how fast the larger images galleries load with fancybox. I could be out of my mind. But I tried it out and I definitely saw some serious slow loading or never loading when I was in www.mydomain.com. and was trying to load a gallery located with just http://mydomain.com. If you switch to www. in Settings > General you’ll get logged out. But you’ll be able to log back in with the same password and username, don’t worry.

Getting Content From WordPress When Your Webstore Is Hosted By LightSpeed

If you’re someone who does this kind of thing (customizing LightSpeed Web Stores) and you also like to use WordPress to run the “main site” – main site being everything else in the Web site that is not the actual Web Store – you’ve probably often been disappointed at the rule that you can’t install WordPress on a LightSpeed hosted server.

LightSpeed offers great hosting & support packages, but just for their native eCommerce solution, Web Store. The hosting plan they offer will not provide email@yourdomain.com and will not host a Content Management System like WordPress which requires a MySQL database (and runs tons of queries and could get hacked if it is aged-out:very old and out of date and/or uses a theme that is very old and out of date. Age-ing out can happen since not all WordPress users know the dangers of letting their install or themes get all old and sit there begging to be hacked).

Again, LightSpeed offers hosting for Web Store and that is all they host. I do not blame them or think they are being too strict or whatever. They have to protect their servers.

Which means if you want a Web site (not “just” a Web Store) and have email@yourdomain.com and all of that, they assume you will buy an additional hosting plan with another Web hosting company.

The thing is, although most business already have a site with a server that can probably run Web Store, they’re sold the hosting package for Web Store when they purchase the license for it. And then a good amount of my clients come to me with their Web Store hosted by LightSpeed and their Web Site hosted by whatever hosting company. I either end up letting them know that their Web Store will have to be kind of not as awesome or I tell them that in order to get WordPress stuff in a Web Store they have to be on the same server – then let them decide if they want to make a change in hosting.

My latest project was set up exactly as described above. I’d gotten so many project requests that I mixed up how their hosting was set up. So I’d quoted them the cost of a WordPress/Web Store integration. I would not have minded reducing the quote to just a LightSpeed Web Store customization but I felt bad that I had promised them all this other good stuff. Forget money, I wanted to see if I could actually do it. I got into this business because I enjoy challenges and problem solving and what is Web site development if not a series of challenges requiring problem solving?

So, The Problem:
How to get WordPress stuff (pages, posts, custom post types, sidebars and menus) to show up in a Web Store?

I tried my usual Simple HTML Dom but it didn’t fly. SHD is what I usually use to get Web Store stuff in WordPress. But the other way around was always a bit of a mess. So I gave up on Simple HTMl Dom. I’ll still use it when I can, though.

What about JSON? Can’t you use JSON to get content from somewhere and spit it into a div? Sure you can but what about Same Origin Policy? Oh, right. Has to be JSONP, then. To test JSONP, I used a service offered by Any Origin and it worked, sort of. I mean it worked swell: it spit the content into a div and blah blah. The issue was really the content it was getting also included the WordPress Header & Footer and everything else in the theme file the page,post or whatever was using. I’d like to avoid getting into a whole WordPress theme tutorial here but basically the way around this was to make a page and then make it use a theme file that only had the content I wanted to show, no sidebars, headers or footers.

So by now you’re probably guessing that I don’t know JSON from a hole in the ground. If I did wouldn’t I be able to target the div I wanted to show the content from? Yeah, but I didn’t know how to do that. 20 minutes into my 1st test case using JSON I was just happy to get something working. I figured I’d have time later to make things more suited for a production environment.

Sooo, the thing I did know how to do was to make a theme file that only had the template tag for the thing I wanted to get. For example, a custom menu. I made a Custom Page file and put the template tag for the specific menu I wanted and saved it as json.php. Then I made the Page and made it use the Custom Page. When I viewed the page all I saw was the plain list of menu items. Great! Wouldn’t work stand alone but would work as a way to only show the menu:

[php]<?php
/**
* Template Name: getwpmenupleeez
*
* A custom page template to get a custom menu.
*
* The "Template Name:" bit above allows this to be selectable
* from a dropdown menu on the edit page screen.
*
* @package WordPress
*
*/

wp_nav_menu( array(‘menu’ => ‘my-pages’ ));

?>[/php]

My-pages being the custom menu I created by going to Dashboard > Appearances > Menus and making a menu named My Pages. In Dashboard > Pages, I created a Page called Just the Menu which had a slug just-the-menu. When I viewed http://myawesomeproject.com/just-the-menu/ all I saw was just the menu. myawesomeproject.com is not a real address.

So in Web Store land I went to templates/my-template/index.tpl.php and located the area of the document into which I wanted to embed Just the Menu.

Like this:

[php]
<script type="text/javascript">
$.getJSON(‘http://anyorigin.com/get?url=myawesomeproject.com/just-the-menu/&callback=?’, function(data){
$(‘.the-menu’).html(data.contents);
});

</script>
<div class="the-menu"></div>[/php]

myawesomeproject.com is not a real address.

The beauty of this is that I’d already styled the menu in my WordPress theme style.css. I didn’t have to make new style for .the-menu because it inherited the style from the theme. If there’s anything I hate it’s doing the same work 2 times.

Anyway such triumphs may seem small but add them up and they’re very big. Nothing makes me happier than to be able to get around a problem.

Have fun!

Ways to add social buttons to LightSpeed Webstore

When it comes to adding social sharing buttons to LightSpeed webstore you can choose a quick and easy fix like Sharethis or add the buttons manually. If you use Sharethis you can customize the buttons. If you add the button using the site’s button code you have to use that site’s button style. This rule is usually laid out in black and white on the site’s terms of use page. Sharethis’ look and behavior is not to everyone’s taste but it is a heck of a lot easier to use.

Most clients want the usual suspects: Twitter and Facebook. Other clients want Pinterest as well and then there’s Svpply.

The Svpply social sharing button is not a common request from clients. Only one client has asked me to add the button to their webstore. So I got the code from the Svpply site and added it and styled it, case closed. Soon after I heard from the client that nothing was happening when they clicked the button. So I had to check out why.

To my knowledge Svpply is a relatively new social sharing site. Because it’s so new hardly anyone is using it and I couldn’t find any information on adding the Svpply button. The Svpply website is the only place to go for help. Their tech support probably would have tried to help me but I really didn’t feel like explaining how webstore shows product images and why their button wasn’t working on my project.

Svpply posts won’t work if the code in the button can’t find the product image. Webstore’s product image (in the single product details pages) is not an actual inline image; it’s a background image. So that is why the Svpply code can’t find it. And that is why the button didn’t work out of the box.

In your webstore template find the product image tag (in product_details.tpl.php), it looks like this:

[php]<?php $this->pnlImgHolder->Render(); ?>[/php]

You can get the main product image to display as an inline image with this code:

[php]<img src="index.php?pdetailimage=<?php echo ($this->prod->ImageId)?>.jpg" alt=""/>[/php]

When I customize a webstore I usually wrap the Product Image tag with a div (for long and boring Internet Explorer related reasons) so all I needed was to add the second line of HTML containing the inline image.jpg and give that one a z-index less than the div that wraps the product image tag.

I gave div#imgHolder a higher z-index (z-index:2).
I gave div#inlineImage z-index:1. As far as the Svpply button is concerned there’s now an inline image on the page.

Here’s the HTML:
[php]<div class="imgHolder"><?php $this->pnlImgHolder->Render(); ?></div>
<div class="inlineimage"><img src="index.php?pdetailimage=<?php echo ($this->prod->ImageId)?>.jpg" alt="" title=""/></div>[/php]

The downside is that no matter what image is being highlighted by the Svpply button, only the main product image will get posted on Svpply. Visitors using the button might choose a detail image and wonder why that image doesn’t show up. But I’m confident that it won’t cause any riots.

[php]<div id="supply" class="social_button">
<script src="//svpply.com/api/all.js#xsvml=1" type="text/javascript" ></script>
<sv:product-button type="boxed" ></sv:product-button>
</div>[/php]

Pinterest’s button code requires a complete URL for the product and the product image.
This code gets the large size of the main product image which will look better on a board than a little thumbnail-sized image.

Make sure to replace http://www.mywebstore.com/ with the real domain and path to webstore.
Example, if your domain is superfab.com and your store is located at superfab.com/store/ you’d need to add http://www.superfab.com/store/.
If your store is in the domain root just add http://www.superfab.com/. If you’re hosting with LightSpeed your store is in the root.

[php]<div id="pinterest" class="social_button">
<a href="http://pinterest.com/pin/create/button/?url=http://www.mywebstore.com/index.php?product=<?php echo($this->prod->Code)?>&amp;media=http://www.mywebstore.com/index.php?pdetailimage=<?php echo ($this->prod->ImageId)?>.jpg" class="pin-it-button" count-layout="horizontal"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a>
</div>[/php]

Twitter’s button code requires a complete URL for the link to the product in the tweet.
Make sure to replace http://www.mywebstore.com/ with the real domain and path to webstore.
Example, if your domain is superfab.com and your store is located at superfab.com/store/ you’d need to add http://www.superfab.com/store/.
If your store is in the domain root just add http://www.superfab.com/. If you’re hosting with LightSpeed your store is in the root.

[php]<div id="twitter" class="social_button">
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.mywebstore.com/index.php?product=<?php echo($this->prod->Code)?>" data-text="<?= $this->prod->DescriptionShort ?>" data-count="none">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</div>[/php]

Facebook’s button code is hard to add to webstore only because the default width is 450 pixels and most webstore product details containing divs don’t have that much room to devote. It also makes it hard to show the Facebook button in a row of other buttons.Thankfully other buttons are not wide.The width of the Facebook button might be why most designers put it last in the row. You can make the button width a lot smaller though – here I’ve made it 150 pixels. It will work ok if your template’s containing div isn’t using overflow:hidden. When I write “button width” I’m not referring to the image of the button.

[php]<div id="facebook" class="social_button">
<fb:like href="index.php?product=<?php echo($this->prod->Code)?>" send="false" width="150" show_faces="false" layout="button_count" font="lucida grande"></fb:like>
</div><script src="https://connect.facebook.net/en_US/all.js#xfbml=1"></script>[/php]

Facebook needs 1 additional javascript file at the bottom of product_details.tpl.php after all the rest of the code in that file.

[php]<script type="text/javascript">
FB.init({
status : true,
cookie : true,
xfbml : true
});
</script>[/php]