LightSpeed Webstore: Don’t want button count in twitter button? Edit sharing.tpl.php

After spending a stupid amount of time trying to fit all the sharing buttons side by side in the exact same vertical alignment in a really small space (256 pixels with some padding on the left) I was about to shoot myself.

Instead, I decided to just go to Twitter and create the button all over again and stick the new code in sharing.tpl.php. The new button I made did not have button count turned on.

https://twitter.com/about/resources/buttons#tweet

Why did I not want the button count? Because with the button count turned on the Twitter button was created by JavaScript to be 120 pixels in width and had to be placed last or there was a big old gap between it and the next button. The actual size of the button is really only about 56 pixels. It’s the button count that adds all the extra width.

I opened mytemplate/sharing.tpl.php and found the twitter button stuff highlighted it and pasted this code in its place:

<a href="https://twitter.com/share" class="twitter-share-button" 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>

You’ll notice the default twitter button code already has the data-count=”none” so what gives?

I have to admit I have expended as many braincells as I care to with this issue so I am not using any more trying to figure out why the default button code with data-count=”none” showed the button count but the one I got over at Twitter’s button maker didn’t.

Fixing A WordPress Theme to Work with WP-E-Commerce 3.8.9 (or whatever)

I was contacted to fix a WP theme I did not design called Kassyopea – a premium theme that costs $55 for a regular license, $2750 for an extended license.

Error number 1: clicking the add to cart button with Fancy Notifications turned on showed the item in the fancy notification message overlay but didn’t actually add the item to the cart (going to check out you got the message “oops cart is empty”).With Fancy Nootifications turned off all you saw when clicking add to cart was “..Updating” and a little spinner icon but that’s it.Updating never went away and the items were never added to the cart.

So off I went to getshopped.org to check out the user forums and saw this exact same issue was marked Resolved, a rare thing if you’ve ever visited a forum for help with your exact issue. A user suggested de activating all the plugins except the shopping cart and switching over to TwentyEleven ( or any other “proven” WP theme) then go to Settings > Store and then to Presentation and click Flush Theme Cache a few times. I also turned off Fancy Notifications in Settings > store > Presentation. After I did that I went back to the shop and added something to the cart, now the add to cart button worked. I re activated the plugins and switched back to Kassyopea and then went back to Settings > Store and then to Presentation and clicked Flush Theme Cache a few times and then a few more times just to be safe.
The add to cart button worked with Fancy Notifications turned back on – one issue fixed!

Now we just had to deal with the fact that after the normal product listing – about 4 or 5 un-styled, duplicated products were also appearing on the page.
I had fixed this before – it’s always a matter of placing wp_reset_query(); in the right place…

Being too lazy to get an FTP login set up I went right over to Appearance > Editor > page.php and experimentally – just to see what would happen – clicked save without editing anything. Big oops now the page displayed with a big PHP error – somehow just saving the page did something bad!

Oh fab, can I please debug code I didn’t write? That’s what I like to do in my spare time, yay. Unfortunately I didn’t save the original but here is the corrected code in page.php:

if( is_front_page() || is_home() ) {
	add_filter( 'body_class', create_function( '$classes ="", "$classes[] = wpsc;" return $classes;' ) );
	get_template_part( 'home', 'store' ); 
	die;
}

After the last curly brace I added wp_reset_query(); now the code looks like this:

if( is_front_page() || is_home() ) {
	add_filter( 'body_class', create_function( '$classes ="", "$classes[] = wpsc;" return $classes;' ) );
	get_template_part( 'home', 'store' ); 
	die;
}
wp_reset_query();

No more duplicated products on the Shop using WP theme Kassyopea.

So there you have it. If you are having the problem where your add to cart button doesn’t work try switching to a different theme and in Presentation flushing the theme cache 2 or 3 times.Most plugin authors will say it’s another plugin and that is true some of the time but the other part of the time it’s usually the theme you’re using.

And you’re seeing duplicated products it’s probably because there is something like this in the theme:

if( is_front_page() || is_home() ) {

//special code 

}

Update

After I wrote this the site owner wrote me to tell me that the add to cart button wasn’t working. I did everything all over again and tested the button. It worked.
Then I cleared the cart items and it didn’t work. The add to cart button always worked with TwentyEleven and TwentyTen even after I cleared cookies. I poked and prodded and changed settings and etc, etc, etc nothing helped. The add to cart button just didn’t work.

Unfortunately I ended up giving up on fixing it.

The weirdest part of this whole thing was the site owner had the almost exact same site set up using the exact same theme with almost exact same domain (other domain ended in .com, this one ended in .com.au). On this set up the Home page contained the productspage shortcode and also had a products Page that also had the products page shortcode. On this site, the add to cart button worked all the time! What a head scratcher.

LightSpeed Webstore Customization Tip: change default button value, CSS class

Hey there customizers,

here’s a small trick I figured out about changing button values ( the text of a button, e.g., “Submit” ). A trick I turned up when I was stressing about having to edit a core file in order to deliver the same copy as was indicated in the mockup.

If you’re working as much as me, you can’t possibly keep track of every line you edited in core of every site you hand off when prepping for webstore version upgrades ( for every site you maintain). Not that you should ever edit core – but, unfortunately there’s a lot of plain text in LightSpeed Webstore that’s sequestered in core files and sometimes you have to.

Most clients have no idea that most of this stuff is in core – they see “Shipping is the same as Billing address” and they want it to read “My Billing & Shipping Address are the Same for This Order”. While I can go into /where-webstore-is-installed/xlsws_includes, find the file that contains the line “Shipping is the same as Billing address” and edit it, I’m not supposed to. Not that it will break stuff (editing plain text rarely breaks anything) but imminent upgrades will possibly overwrite the edit and I might not remember to add it back.

Because of this issue I’m always looking for ways to edit stuff without touching core so when I saw this line in /templates/deluxe/promo_code.tpl.php which renders the submit button for the Promo Code input field:

<?php $this->btnPromoVerify->Render('Text='._sp("Apply Promo Code")) ?>

I tried it out on other render hooks and found out I could use it practically anywhere I wanted to. I could also use this other handy line I’d seen sprinkled about in template files which generates the CSS class for a HTML element such as for the Login/Register buttons in
/templates/deluxe/checkout_login_register.tpl.php:

 
<?php $this->butLogin->Render('CssClass=button rounded') ?> 
<?php $this->butRegister->Render('CssClass=button rounded') ?>

I combined the lines in one render hook and was real (stupidly pleased) with myself. Example:

<?php $this->whatEver->Render('CssClass=awesome',
'Text='._sp("Awesome")) ?>

Keep your eyes peeled for $this->something->Render() in your templates and try it out for yourself.

A Myrtle Walgreens Manager’s Method of Customer Service Angers Me

I’ve been going to the Myrtle Walgreens at least 3 times a month since it opened over 2 years ago and I spend a silly amount of money there.
Last night, on my second visit this week, I asked for 10 dollars cash back before I paid with my debit card. I was given my receipts and 3 or 4 coupons and my shopping bags but not the $10.

But I didn’t know this until I was almost home and I stopped at the corner bodega to buy one last thing, intending to pay with the 10 dollars I’d requested at Walgreens. When I went to pay I had ones and a five in my wallet, no ten dollar bill. I dug into my bag thinking maybe the bill had been wadded up with the receipts and coupons which I’d stuffed into the bottom of my bag – but there was no 10 dollar bill anywhere.

I was close enough to home and also had my dog and was carrying a heavy 12 pack case of diet coke that I didn’t want to turn around and head back up to Walgreens. I figured I could just call them up and settle the matter! I am an optimist by nature but I had doubts I would be believed since it would be a case of my word against the store employee’s. Still, I phoned, got customer service and Brian picked up my call. I told him my story and he said he would check the register if I’d like to call back.

I called back and he said the register came up even and he had also checked the security tapes and the tape showed the sales clerk handing me the 10 dollars. I asked him why would I make up a story about not getting 10 dollars cash back if it weren’t true? A very silly question I admit. There are many reasons for someone to lie about not getting money the main reason being in order to acquire more money. At least he didn’t laugh. He just replied that his information showed the opposite and that was that.

Of course the main responsibility was mine: I should have been more observant. I should have remembered the clerk’s face and name and noticed if he’d handed me the money. But once I got to the line for the register I zoned out and began thinking about work and other stuff. So I didn’t even really look at his face.

So I was a little ticked off at myself I guess but I was more ticked off at that Walgreen’s manager. That he said he had checked the security tapes for the time of my transaction and had seen the clerk hand me $10. Since I had not been handed the money his statement was a false one. I also doubted he’d reviewed the security tape at all. I think he says that to people in similar situations to mine in order to get rid of them. I don’t think it had anything to do with the money – I think it was more important to get rid of me and also shame me a little bit. Conclusion: people can be real dicks and store managers (of large retail chains) are almost always dicks.