The popular open-source contract for web professionals by Stuff & Nonsense
- Originally published: 23rd December 2008
- Revised date: March 15th 2016
- Original post
| <?php | |
| add_action('wp_head', 'webworks_facebook_analytics'); | |
| function webworks_facebook_analytics() { | |
| if(current_user_can('manage_options')) { | |
| return; | |
| } | |
| ?> |
| /** | |
| * Redirect to a specific page when clicking on Continue Shopping in the single product page | |
| * | |
| * @return void | |
| */ | |
| function wc_custom_redirect_continue_shopping( $message ) { | |
| if ( strpos( $message, __( 'View Cart', 'woocommerce' ) ) !== false ) { | |
| $message = str_replace( esc_url( wc_get_page_permalink( 'cart' ) ), esc_url( wc_get_page_permalink( 'shop' ) ), $message ); | |
| $message = str_replace( __( 'View Cart', 'woocommerce' ), esc_html__( 'Continue Shopping', 'woocommerce' ), $message ); |
| remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 ); | |
| add_action( 'woocommerce_proceed_to_checkout', 'change_url_to_checkout', 20 ); | |
| function change_url_to_checkout() { | |
| $cart = WC()->cart->get_cart(); | |
| $url = ''; | |
| foreach ( $cart as $item ) { | |
| if ( $item['product_id'] === 70 ) { | |
| $url = 'put_your_extra_page_url_here'; | |
| break; |
| /** | |
| * 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 { |
| // 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(){ |
| // 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' ); |
| // 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, '.'); | |
| <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> |
| foreach (dirname((__FILE__)) as $filename) { | |
| $path = plugin_dir_pathdirname(dirname(__FILE__)) . 'includes/partials/' . $filename; | |
| if (is_file($path)) { | |
| require $path; | |
| } | |
| } |