Skip to content

Instantly share code, notes, and snippets.

View warnakey's full-sized avatar

warnakey

View GitHub Profile
@warnakey
warnakey / WooCommerce-disable-UPS-shipping-options-if-shipping-to-a-PO-Box.php
Created August 20, 2021 06:16
Code for WooCommerce site to disable UPS shipping options if shipping to a PO Box (because UPS doesn't ship to PO Boxes)
<!-- You can add this to your footer.php file -->
<!-- UPS does'nt ship to PO Boxes, so if your site has multiple carriers (ex. USPS, FedEx & UPS) you would disable UPS for PO boxes -->
<!-- ** REPLACE ** the ID below to be the one for your WooCommerce checkout page !!!!!! -->
<?php if($post->ID == 2309) { // only works on checkout page ?>
<script>
// find the billing and shipping email fields to use for event listeners
// This code will fire when the customer clicks off of either email field
@warnakey
warnakey / Prevent-Spam-Robot-From-Completing-WooCommerce-Orders-Based-On-City.php
Last active August 18, 2021 22:57
This code prevents Spam robots from completing orders on WooCommerce if they type the city field as 'dsfsdf' then kicks them off the website
/* You can put this in your footer.php file */
/* This code checks if Spam robots type the City field in the WooCommerce checkout page as 'dsfsdf' and kicks them out */
/* This can be modified to any condition you like by changing the if statements and event listeners around */
<?php if( $post->ID == 2309 ) { ?> // change this to your Checkout page's ID
<script>
// get variables for the different fields in the woocommerce checkout form (note 'billing' vs 'shipping' side)
var cityfield = document.getElementById('billing_city');
var postfield = document.getElementById('billing_postcode');
<!-- You could put this in your footer.php file near the bottom -->
<!--Function to find out what time it is, so we can disable some shipping options from Friday 2pm EST through Monday at midnight EST.-->
<?php if( $post->ID == 2305 || $post->ID == 2309) { // **REPLACE** these IDs with your CART and CHECKOUT pages! *important*
// Function to get the day of the week. Returns 0 through 6. Sunday = 0, Saturday = 6.
function getWeekday($date) {
return date('w', strtotime($date));
}
// You can find out what day of the week any date is like this
// echo "The day of the week is: ";
@warnakey
warnakey / custom-klaviyo-form.html
Created August 17, 2021 00:20
Custom Klaviyo Form With Radio Buttons
<!-- REPLACE ALL INSTANCES OF "LIST_ID" WITH YOUR KLAVIYO LIST ID! THIS IS VITALLY IMPORTANT -->
<form id="contest_week_one" class="klaviyo_styling klaviyo_gdpr_embed_LIST_ID" action="//manage.kmail-lists.com/subscriptions/subscribe" data-ajax-submit="//manage.kmail-lists.com/ajax/subscriptions/subscribe" method="GET" target="_blank" novalidate="novalidate">
<input type="hidden" name="g" value="LIST_ID">
<input type="hidden" name="$fields" value="$consent">
<input type="hidden" name="$list_fields" value="$consent">
<div class="klaviyo_field_group">
<!--<label for="k_id_first_name">First Name</label>-->
<input class="" type="text" value="" name="first_name" id="k_id_first_name" placeholder="First Name" />
<!--<label for="k_id_last_name">Last Name</label>-->
<input class="" type="text" value="" name="last_name" id="k_id_last_name" placeholder="Last Name" />
@warnakey
warnakey / functions.php
Created August 7, 2021 07:38
WooCommerce - Place Orders On Hold if billing and shipping information are different
<?php
/* PLACE ORDERS ON HOLD WHEN BILLING & SHIPPING INFO DO NOT MATCH */
add_action( 'woocommerce_thankyou', 'woocommerce_billing_shipping_address_match', 10, 1);
function woocommerce_billing_shipping_address_match( $order_id ) {
if ( ! $order_id ) {
return;
}
// Get the order id
$order = wc_get_order( $order_id );
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "VideoObject",
"name": "Child Custody",
"description": "One of the most litigated issues that can arise during a divorce is child custody and visitation. North Carolina law provides that custody determinations are to be made in the best interests of the child.",
"thumbnailUrl": "https://www.divorceistough.com/wp-content/uploads/2019/03/child-custody-video-thumbnail.jpg",
"uploadDate": "2017-08-08T09:48:00-05:00",
"duration": "PT3M31S",
"contentUrl": "https://vimeo.com/228817202",
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "JobPosting",
"datePosted": "2019-09-09T10:25:00-05:00",
"validThrough": "2050-09-21T09:48:00-05:00",
"title": "Crew Member",
"description": "Crew member positions include: cashiers, cooks, grill, dining room attendants, biscuit makers and drive-thru. Must be at least 16 years old. Successful candidates are passionate about customer service and serving high quality food with a smile. Candidates must be able to manage many time-sensitive tasks simultaneously, are extremely organized, have high standards of professionalism, have a positive attitude and are team players.",
"skills": "Passionate about customer service and serving high quality food with a smile. Candidates must be able to manage many time-sensitive tasks simultaneously, be extremely organized, have high standards of professionalism, have a positive attitude and are team players.",
"employmentType": "Fu
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Product",
"name": "Sentinel Primary Care",
"description": "Sentinel Primary Care is a general internal medicine practice where we provide primary care for individuals 18 years old and older. We opened our doors in 2017 to offer Triangle residents top-notch primary care services in an attentive, membership-model setting. At Sentinel we get to know each person individually to give better primary care.",
"image": "https://sentinelprimarycare.com/wp-content/uploads/2018/09/SENTINEL-logo.png",
"itemCondition": "https://schema.org/NewCondition",
"brand": { "@type": "Brand", "name": "Sentinel Primary Care" },
"aggregateRating": { "itemReviewed": "Sentinel Primary Care", "worstRating": "1", "bestRating": "5", "ratingValue": "5", "reviewCount": "3" },
<!-- This is for a single page that lists a group of products on it -->
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "ItemList",
"url": "https://www.myexamplestore.com/products/",
"numberOfItems": "2",
"itemListElement": [
{
"@type": "ListItem",
@warnakey
warnakey / speakable-schema.php
Last active April 15, 2019 18:47
Speakable Schema Example for WordPress (will use the meta description of each page for the speakable schema)
<!-- This schema can go in the header.php file of any WordPress site -->
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "WebPage",
"name": "<?php the_title(); ?>",
"speakable":
{
"@type": "SpeakableSpecification",
"xpath": "/html/head/meta[@name='description']/@content"