jQuery conflict in WordPress 4.5 and WooCommerce 2.5

If your WooCommerce site is having a problem since you upgraded your WordPress to version 4.5, the problem might be associated with jQuery version that came with the new WordPress.

WordPress 4.5 “Coleman” comes with jQuery 1.12.3, the first version 1.12.0+. Previously it was using 1.11.x.

Check to see if your site generates script error(s). My script error after the WordPress upgrade was

 Syntax error, unrecognized expression: a[href*=#]:not([href=#])

I discovered when I wasn’t able to add a variable product to a shopping cart (the product page did not show the product price after all the options are selected, and displayed “please choose options” message)

Solutions

If you haven’t upgraded WordPress 4.5, my recommendation is to hold off the ugprade for now. If you already have upgraded, then you can add the following code to your theme’s functions.php to downgrade jQuery version:

// Downgrade to jQuery given version
function downgrade_jquery() {
  global $wp_scripts;
 
  if ( !is_admin() ) :
    wp_deregister_script('jquery');
    wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js', false, '1.11.3');
  endif;
}
add_action( 'wp_head', downgrade_jquery() );

How to darken post background images in Fable theme 1.7.4

The theme I’m currently using for this site is Fable Theme by Elegant Theme.

One of the issues I recently dealt was how I have to be picky about selecting featured images for each post. The featured image is used as the background image for each post on homepage and archive pages. And by default, when there is an featured image assigned to a post, the font color of the post title and its summary is white.

Initially, I darken the text shadow to make the text more readable. But depending on the image I picked, it wasn’t an effective solution for some posts.

So I decided to apply linear gradient over the post background/featured image to make it little darker to give little more contrast between the text and the image.

Unfortunately, you can’t simply overwrite style.css in this case. The themes uses a function, et_fable_get_background(), to insert background-image property in the section in content.php

So in order to make the change, you need to modify two files in the child theme folder.
Continue reading “How to darken post background images in Fable theme 1.7.4”

A step toward quitting cigarettes

So there, my biggest weakness…smoking. Among many things that I enjoy, smoking is the only thing that I can’t seems to control. I LOVE bacon, but I can go without bacon for days, weeks, or months. I LOVE drinking wines, but I can take a break from any alcohol beverages for months. But cigarettes…not a chance.

Yes, I did the patches, the gum, and the prescriptions…you know the standards. There are times I was able to stop smoking for months…but every time I went back eventually.

The problem is, though I know it is driven by addiction, I can’t stop enjoying smoking. The alternatives were simply NOT enjoyable. It leaves me frustrated and pissed off…and the frustration grows the longer I stay away from smoking. It never got better.

That is until I got introduced the world of vaping about a week ago.

Hello? How come I didn’t get hooked on this sooner?

The biggest thing is I ENJOY vaping. It doesn’t make me frustrated. The day I started vaping is the day I stop smoking cigarettes…well almost (I went for a couple of cigarettes while the battery had to be charged for hours). This is the first alternative method that doesn’t make me miss smoking. I prefer the taste of vapor over cigarettes.

I love the fact that I don’t smell like cigarettes, that my next car won’t be stinky, that I don’t accidentally make a cigarette burn on anything, that cost much less than buying a pack of cigarette at a gas station (after a bit of investment on the equipment but you’ll get that back in time). And I love the fact that I can control the nicotine intake without a waste. So many times, I just want to get little of smoke, not the whole cigarette. I tossed out so many less than half smoked cigarette butts before.

The bottom line is, THIS already allowed me to breakaway from cigarettes with such an ease. I’m hopeful that this will be my permanent goodbye to cigarettes. Yes, it’s only a week so far, but I’m very optimistic this time.

Note: I am not encouraging anyone to start vaping. As far as I know, there is no conclusive research result that show vaping is a better alternative to smoking cigarette or a suitable smoking cessation method. There is no understanding of long-term health effect of vaping either. I STRONGLY discourage people from vaping especially if you are not addicted to smoking already.

How to sort grouped product’s children in WooCommerce 2.5.x

You MUST backup your database and your web files before you try this method.  If you decide to try this method, please do so at your own risk. I will not be responsible for any site breakage.

The order of child products in a group product page in WooCommerce is based on “menu_order” value in ascending order. You can change each product’s menu order value in “Edit Product” page under “Advanced” tab.

The problem is you can’t go through this process when you have hundreds or thousands or products and finish in timely manner.

There are several ways you can do to re-sort your child products in much faster manner.
Continue reading “How to sort grouped product’s children in WooCommerce 2.5.x”

Recreate Cazbah legacy platform’s product table in MySQL

CREATE TABLE products (
productActive bit(1),
productCategoryname varchar(500),
productSku varchar(500),
productName varchar(500),
productLongdesc text,
productPrice  double,
productMSRPActive bit(1),
productMSRPLabel varchar(500),
productMSRPPrice  double,
productMSRPSeparator varchar(500),
productMSRPColor varchar(500),
productWeight double,
productShipprice  double,
productFreeshipping bit(1),
productPic varchar(500),
productPicurl varchar(500),
productPiclink varchar(500),
productSubtitle varchar(500),
productThumbnailPic varchar(500),
productThumbnailurl varchar(500),
productDisplayOrder int,
productTrackInventory bit(1),
productCurrentInventory double,
productVariablePricing bit(1),
variationSku varchar(500),
variationDisplayName varchar(500),
variationInvoiceName varchar(500),
variationPrice double, 
variationMSRPActive bit(1),
variationMSRPLabel varchar(500),
variationMSRPPrice double, 
variationMSRPSeparator varchar(500),
variationMSRPColor varchar(500),
variationWeight double,
variationShipprice double,
variationPicUrl varchar(500),
variationActive bit(1),
variationFreeshipping bit(1),
variationDisplayOrder int,
variationTrackInventory bit(1),
variationCurrentInventory double,
variationVariablePricing bit(1),
questionWording varchar(500),
questionDisplayOrder int,
questionAnswerRequired bit(1),
questionDropDownAnswers bit(1),
questionPriceChange double,
questionLongText text,
answersDisplayName varchar(500),
answersInvoiceName varchar(500),
answersDisplayOrder int,
answersPriceChange double,
googleCategory text,
productGglProdCondition varchar(500),
productGglOnlineOnly bit(1),
productGglGTIN varchar(500),
productGglMPN varchar(500),
productGglBrand varchar(500),
productGglColor varchar(500),
productGglSize varchar(500),
productGglMaterial varchar(500),
productGglPattern varchar(500),
productGglAgeGroup varchar(500),
productGglGender varchar(500),
choiceGglProdCondition varchar(500),
choiceGglVariant bit(1),
choiceGglOnlineOnly bit(1),
choiceGglGTIN varchar(500),
choiceGglMPN varchar(500),
choiceGglBrand varchar(500),
choiceGglColor varchar(500),
choiceGglSize varchar(500),
choiceGglMaterial varchar(500),
choiceGglPattern varchar(500),
choiceGglAgeGroup varchar(500),
choiceGglGender varchar(500)
);

WooCommerce 2.3.8 – how to set minimum order amount for a product

It’s not uncommon to be asked to implement minimum checkout requirements to WooCommerce Cart. The common requirements are:

  • Minimum Dollar Amount Per Order
  • Minimum Number of Products Per Order or Per Products

Luckily, there is a great tutorial for implementing these by Yojance Rabelo.

But the other day, I got a request to implement minimum dollar amount PER PRODUCT…not too common, but not never-heard-of either.

So I decided to tweak Yojance’s Minimum Dollar Per Order code to set minimum order amount for a product instead of for the entire order: Continue reading “WooCommerce 2.3.8 – how to set minimum order amount for a product”

Make PHP Mail() work in AWS EC2 – Ubuntu 14.04

AWS IP addresses can be problematic for setting an email server in an EC2 instance…even with right setup email sent from the IP address can be marked as spam.

So what to do with setting up SMTP for your web applications? One alternative is to use AWS SES service. I decided not to use SES, however, because 1) each email address or domain needs to be approved and 2) there is cost associated with number of email sent out. These aren’t too bad of the restrictions but I wanted something that JUST work without configuring every time I build a website.

I went with MSMTP to use my gmail account to send email message by default. I can also overwrite the smtp setting per linux account. So if I were to host sites that are not mine, they can use their own smtp setup.
Continue reading “Make PHP Mail() work in AWS EC2 – Ubuntu 14.04”

Problem with linking models containing multiple words in CakePHP

I had two models, “Example” and “ExampleModel”, linked with belongsTo – hasMany relationship.

The problem was, after baking, the dropdown selection for ExampleModel in Example’s add and view pages were totally blank. Yet, in the index page, the data is shown (which means that relationship is established correctly). Continue reading “Problem with linking models containing multiple words in CakePHP”

Chromebook basic tweaks and tips for Crouton

Here are the first set of basic applications that I installed in my Ubuntu environment. All the applications (including Ubuntu OS) took about 2 GB of disk space.  If you are NOT planning to use Ubuntu on regular basis ,and just wanted to install essential applications that are not available in Chrome OS, the default 16GB of disk space is more than enough to install all for the following applications.
Continue reading “Chromebook basic tweaks and tips for Crouton”

WooCommerce 2.1.9 cheatsheet – product listing page

How To Change Number Products Displayed Per Page

Insert the following code in your theme’s functions.php

// Display 40 products per page. 
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 40;' ), 20 );

Continue reading “WooCommerce 2.1.9 cheatsheet – product listing page”