Skip to content

Instantly share code, notes, and snippets.

@WPDevHQ
WPDevHQ / _base.scss
Created March 19, 2016 02:36 — forked from yratof/_base.scss
WooCommerce Checkout for Mobile
@media only screen and (max-width: 760px) {
.woocommerce-cart #content .woocommerce table.shop_table td,
.woocommerce-cart #content .woocommerce-page table.shop_table td,
.woocommerce-checkout #content .woocommerce table.shop_table td,
.woocommerce-checkout #content .woocommerce-page table.shop_table td {
padding: 3px 0;
border-top: 0;
}
@WPDevHQ
WPDevHQ / woo-custom-redirect
Created August 6, 2016 23:00 — forked from anant1811/woo-custom-redirect
Woocommerce - custom redirection on checkout
//*Add custom redirection
add_action( 'template_redirect', 'wc_custom_redirect_after_purchase' );
function wc_custom_redirect_after_purchase() {
global $wp;
if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) {
wp_redirect( 'http://mysite.com/thank-you-for-your-order/' );
exit;
}
}
@WPDevHQ
WPDevHQ / 0_reuse_code.js
Created August 10, 2016 05:51
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@WPDevHQ
WPDevHQ / font-awesome.php
Created August 23, 2016 11:27 — forked from justintadlock/font-awesome.php
PHP array of Font Awesome icons.
<?php
// Font Awesome v. 4.6.
function jt_get_font_icons() {
return array(
'fa-glass' => 'f000',
'fa-music' => 'f001',
'fa-search' => 'f002',
'fa-envelope-o' => 'f003',
@WPDevHQ
WPDevHQ / foreach
Created September 2, 2016 11:19 — forked from dsgnr/foreach
foreach (dirname((__FILE__)) as $filename) {
$path = plugin_dir_pathdirname(dirname(__FILE__)) . 'includes/partials/' . $filename;
if (is_file($path)) {
require $path;
}
}
@WPDevHQ
WPDevHQ / iaf-plugin.php
Created October 8, 2016 12:40 — forked from nickdgreen/iaf-plugin.php
liveEstimatePHPCode.php creates a form to collect inputs from a client and then calculates the estimated courier charge based on the type of vehicle and the distance using UK post codes. iaf-plugin.php appears to create a widget (i.e. it appears in the widget menu) but when added to a page nothing is dispalyed.
<form action="#formend" method="post"><input name="submited" type="hidden" value="true" />
<table border="0" width="450px">
<tbody>
<tr>
<td width="200px">Collection Postcode:</td>
<td width="250px"><input name="fromCode" size="10" type="text" value="" /></td>
</tr>
<tr>
<td>Destination Postcode:</td>
<td><input name="toCode" size="10" type="text" value="" /></td>
@WPDevHQ
WPDevHQ / perfect_excerpt.php
Created December 7, 2016 17:32
Perfect Excerpts for WordPress
// if you're tired of excerpts cutting in half, here it is, the perfect solution
// that shortens your excerpt to full sentences in your characters limit.
<?php
function perfect_excerpt( $length ) {
$excerpt = get_the_excerpt($post->ID);
$short_excerpt = substr($excerpt, 0, $length);
// look for the last period
$finishline = strrpos( $short_excerpt, '.');
// Get The Page ID You Need
get_option( 'woocommerce_shop_page_id' );
get_option( 'woocommerce_cart_page_id' );
get_option( 'woocommerce_checkout_page_id' );
get_option( 'woocommerce_pay_page_id' );
get_option( 'woocommerce_thanks_page_id' );
get_option( 'woocommerce_myaccount_page_id' );
get_option( 'woocommerce_edit_address_page_id' );
get_option( 'woocommerce_view_order_page_id' );
get_option( 'woocommerce_terms_page_id' );
// Add to a js file in your theme/child theme or create a new js file. If you create a new file, remember to enqueue from functions.php. See example below.
// Adds thumbnail hover to main product img
jQuery(document).ready(function($) {
// Get the main WC image as a variable
var wcih_main_imgage = $( 'a.woocommerce-main-image' ).attr( 'href' );
// This is what will happen when you hover a product thumb
$(".thumbnails a").hover(
// Swap out the main image with the thumb
function(){
@WPDevHQ
WPDevHQ / style.css
Created December 31, 2016 00:18
On single product page, default WooCommerce css use equal width for product image (left) and product summary (right). In a custom project, sometimes you want to make product summary width bigger, for example 73% for your product summary and 23% for your product image. You only need to put this CSS code to the bottom of style.css file in your chi…
/**
* single product page layout *
* 23% (image) + 4% (spacing) + 73% (summary) = 100% *
**/
/* modify product image width */
.woocommerce div.product div.images, .woocommerce #content div.product div.images, .woocommerce-page div.product div.images, .woocommerce-page #content div.product div.images {
width: 23%;
}
/* modify product summary width */
.woocommerce div.product div.summary, .woocommerce #content div.product div.summary, .woocommerce-page div.product div.summary, .woocommerce-page #content div.product div.summary {