Skip to content

Instantly share code, notes, and snippets.

View tharmann's full-sized avatar

Tate Harmann tharmann

View GitHub Profile
@tharmann
tharmann / functions.php
Created March 2, 2020 20:29 — forked from lukecav/functions.php
Set cart expiration interval to 72 hours in WooCommerce
add_filter('wc_session_expiring', 'filter_ExtendSessionExpiring' );
add_filter('wc_session_expiration' , 'filter_ExtendSessionExpired' );
function filter_ExtendSessionExpiring($seconds) {
return 60 * 60 * 71;
}
function filter_ExtendSessionExpired($seconds) {
return 60 * 60 * 72;
}
import csv
with open('wc-product-export-10-5-2023-1683750652005 - wc-product-export-10-5-2023-1683750652005.csv') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
line_count = 0
for row in csv_reader:
if line_count == 0:
line_count += 1
else:
col_count = 0
@tharmann
tharmann / functions.php
Last active March 8, 2024 17:33
Customize WooCommerce Structured Data to load via JS - for cache prevention
<?php
/* remove default WC structured data and add our custom process which adds an id to the script tag and loads the script content via js to avoid caching*/
function remove_wc_sd_output_footer() {
remove_action( 'wp_footer', array( WC()->structured_data, 'output_structured_data' ), 10 );
add_action( 'wp_footer', 'custom_structured_data_output_cb', 10 );
}
add_action( 'init', 'remove_wc_sd_output_footer' );
function custom_structured_data_output_cb() {
$types = cust_get_data_type_for_page();