Featured

What do you need help with?

Start typing your WooCommerce question.

 

Mini plugin: Display Current Server Date and Time

This is a mini plugin that displays the current server date and time on each WooCommerce Single Product page. I use it for troubleshooting timed events linked to WooCommerce orders.

Screenshots

Single Product page:

Screen Shot

 

Download

Download Display Current Server Date and Time

 

Tested with:
WordPress 4.7
WooCommerce 2.6.11

How to reset WP Offload S3 when your S3 bucket has changed

I am a fan of speed optimisation and also like to tinker with WP Offload S3 by delicious brains. Recently I found myself in the need of reseting the media library uploads.

I had cleared my old S3 bucket and created a new one, however WP Offload S3 still insisted on the old bucket. To reset WP Offload S3 and make it forget the old bucket, do the following.

  • Take a full backup of your database
  • Offload S3 media stores the name of the bucket in full in the wp-postmeta table. This value is set for every uploaded media file.
  • Do a search for “full-bucket-name”. It will find the value in the wp-postmeta table and some other places.
  • Drop all the values found in the wp-postmeta table.
  • This does the same as using the “remove from S3” option in the media library.
  • For good measure you can delete all traces you find of the old bucket name in other tables as well. It should do no harm and if it does, you did take that backup, right?

After this your Offload S3 is ready to start fresh and prompts you to upload all your media files.

How to enable WooCommerce Stripe payment gateway debug mode

When things go sideways with Stripe payments using https://wordpress.org/plugins/woocommerce-gateway-stripe/ enable WordPress debug mode and Stripe debug mode. You should enable debug mode as early as you can when you detect failed or double payments. Once your issue is resolved you can turn it off again.

You can find the checkbox for enabling the Stripe debug mode at the end of the plugin settings:

GIF

Too small? View in full size.

How to fix broken links and missing pages in WordPress by resetting permalinks

The permalink structure can get lost sometimes

Sometimes the link structure on your WordPress needs a jumpstart.  After deploying your site, installing new features or just plain high volume day to day operation your links may have moved to places where they don’t belong. If you are seeing unexpected 404 pages, for example with redirection after successful payments in WooCommerce, try resetting your permalinks like so:

Reset permalinks manually

  1. Make a full backup, before you do anything.
  2. Go to General > Permalinks
  3. Whatever your settings are, select a different permalink option and hit Save. Be careful: if you have a custom option, you must save the info entered there manually. It will be gone if you save different options.
  4. After they have successfully changed, revert to your old settings and hit Save again.This rewrites the permalink structure to your database, eliminating corrupt or faulty entries in the process.

Here is a quick screencast illustrating the process:

GIF

Too small? View in full size.

Permalink management plugins

Furthermore there are of course plugins to help you manage your permalinks:

Happy permalink regenerating!

 

How to automatically set all WooCommerce orders to complete

Processing instead of complete because of physical shipment

WooCommerce per default sets all WooCommerce orders to processing after a successful payment. The reason behind this is that it assumes you are selling physical goods that need to be shipped.

Complete WooCommerce orders automatically

For many people this does not fit their use case. You might require all your order to automatically complete all your orders. There are several ways to achieve this.

Happy autocompleting.

How to fix responsive layout issues in WordPress

Responsive layout is an important factor for your website. In order to be able to fix an issue you first must be certain that this is happening to every visitor and not just you. Most people use their own phone for testing which is fine, but if you are collaborating with somebody else to help you fix an issue in your responsive layout you require common testing ground. A browser based testing tool also rules out any local issue on your phone.

Use WordPress customizer or similar browser tool to test

The quickest way to test your responsive layout is provided by the WordPress customizer. Have a look:

GIF

Too small? View full size GIF in new tab

I use Responsinator for extended testing.

Apply CSS for mobile views only

Once you have found the right CSS class to target you need to enter your custom CSS in a way that it targets the correct mobile view.

Mobile views are triggered by CSS breakpoints and require media queries.

You can either enter the correct CSS with a media query manually into a custom CSS field or use a plugin to facilitate this. I like using Responsive CSS Editor.

I hope this information helps you to fix your responsive layout issue.

Code Snippet: Display WooCommerce highest variable product price only

Here is a code snippet that displays the highest price only for WooCommerce variable products instead of the default price range.

add_filter( 'woocommerce_variable_sale_price_html', 'con_show_max_variation_price_only', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'con_show_max_variation_price_only', 10, 2 );
 
function con_show_max_variation_price_only( $price, $product ) {
 
// Main Variation Price
$prices = array( $product->get_variation_price( 'max', true ), $product->get_variation_price( 'min', true ) );

$price = $prices[0] !== $prices[1] ? sprintf( __( '%1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
 
// Sale Variation Price
$prices = array( $product->get_variation_regular_price( 'max', true ), $product->get_variation_regular_price( 'min', true ) );
sort( $prices );

$saleprice = $prices[0] !== $prices[1] ? sprintf( __( '%1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );

//Output
if ( $price !== $saleprice ) {
    
    $price = '<span style="display:none;">' . $saleprice . '</span> <ins>' . $price . '</ins>';
    
    }
    
    return $price;

}

Based on this handy snippet by Gerhard. Not sure how to use this? Here is how to use custom code snippets like this.