Skip to content

Instantly share code, notes, and snippets.

function modify_jquery() {
if (!is_admin()) {
wp_deregister_script('jquery');
wp_register_script('jquery', 'https://code.jquery.com/jquery-1.11.3.min.js');
wp_enqueue_script('jquery');
}
}
add_action('init', 'modify_jquery');
@SirDarcanos
SirDarcanos / functions.php
Last active December 8, 2023 16:29
Adding a PDF Catalog for Your Store
<?php
add_action( 'woocommerce_single_product_summary', 'custom_pdf_catalog_download_button' );
function custom_pdf_catalog_download_button() {
return do_shortcode( '[wc-store-catalog-pdf]' );
}
add_action( 'wcpv_shortcode_registration_form_validation', 'wc_custom_vendors_validation', 10, 2 );
function wc_custom_vendors_validation( $errors, $form_items ) {
if ( empty( $form_items['vendor_description'] ) ) {
$errors[] = __( 'Vendor Description is a required field.', 'woocommerce-product-vendors' );
}
return $errors;
}
add_action( 'get_header', 'remove_storefront_sidebar' );
function remove_storefront_sidebar() {
if ( is_woocommerce() ) {
remove_action( 'storefront_sidebar', 'storefront_get_sidebar', 10 );
}
}
body.woocommerce #primary {
float: none;
width: 100%;
}
function wcs_redirect_product_based ( $order_id ){
$order = wc_get_order( $order_id );
foreach( $order->get_items() as $item ) {
$_product = wc_get_product( $item['product_id'] );
// Add whatever product id you want below here
if ( $item['product_id'] == 70 ) {
// change below to the URL that you want to send your customer to
wp_redirect('http://www.yoururl.com/your-thank-you-page');
}
// Difference for between now and a date in the future
$future_timestamp = strtotime( '1st January 2020' );
$difference = human_time_diff( current_time( 'timestamp' ), $future_timestamp );
// Difference between a date in the past and now
$past_timestamp = strtotime( '1st January 2016' );
$difference = human_time_diff( $past_timestamp, current_time( 'timestamp' ) );
<?php
/*
Plugin Name: Example Scheduled Events
Plugin URI: https://wordpress.org/
Description: This is an example plugin to learn how to use scheduled events
Version: 1.0.0
Author: Your Name
Author URI: https://yoursite.com
Text Domain: egse
*/
@SirDarcanos
SirDarcanos / content-link.php
Created September 5, 2016 06:23
Link post format template for Storefront
@SirDarcanos
SirDarcanos / style.css
Created September 5, 2016 06:24
Style for the post format link on Storefront
/**
* Post format Link
*/
.hentry.type-post.format-link .entry-header {
margin-bottom: 5px;
}
.hentry.type-post.format-link .entry-title {
font-size: 1.618em !important;
}