Skip to content

Instantly share code, notes, and snippets.

AJ Morris ajmorris

Block or report user

Report or block ajmorris

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ajmorris
ajmorris / functions.php
Created Mar 28, 2018
WooCommerce - Adds stock status to the dropdown on product pages
View functions.php
<?php
add_action( 'woocommerce_after_add_to_cart_form', 'dropdown_waitlist_label' );
function dropdown_waitlist_label() {
echo "
<script>
jQuery(document).ready(function($) {
var variation_data = $('form.variations_form').attr('data-product_variations');
var variation_data = JSON.parse(variation_data);
$('#pa_size > option').each(function() {
for (var i = 0; i < variation_data.length; i++) {
@ajmorris
ajmorris / functions.php
Last active Aug 6, 2018
making the description display for menu items with description filled out
View functions.php
<?php
// Adds the descriptions to menu output
function prefix_nav_description( $item_output, $item, $depth, $args ) {
if ( !empty( $item->description ) ) {
$item_output = str_replace( $args->link_after . '</a>', '<p class="menu-item-description">' . $item->description . '</p>' . $args->link_after . '</a>', $item_output );
}
return $item_output;
}
@ajmorris
ajmorris / functions.php
Created Dec 7, 2017
Remove checkout fields from WooCommerce Checkou
View functions.php
<?php
function wc_ninja_remove_checkout_field( $fields ) {
unset( $fields['billing']['billing_company'] );
return $fields;
}
add_filter( 'woocommerce_checkout_fields' , 'wc_ninja_remove_checkout_field' );
// list of fields can be found here, https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/
@ajmorris
ajmorris / functions.php
Created Apr 18, 2018 — forked from mikejolley/functions.php
WooCommerce - Notify admin when a new customer account is created
View functions.php
<?php // Do not include this if already open!
/**
* Code goes in theme functions.php.
*/
add_action( 'woocommerce_created_customer', 'woocommerce_created_customer_admin_notification' );
function woocommerce_created_customer_admin_notification( $customer_id ) {
wp_send_new_user_notifications( $customer_id, 'admin' );
}
@ajmorris
ajmorris / dropdown-stock-status.php
Created Apr 18, 2018 — forked from lawkwok/dropdown-stock-status.php
WooCommerce - Adds stock status to the dropdown on product pages
View dropdown-stock-status.php
<?php
add_action( 'woocommerce_after_add_to_cart_form', 'dropdown_waitlist_label' );
function dropdown_waitlist_label() {
echo "
<script>
jQuery(document).ready(function($) {
var variation_data = $('form.variations_form').attr('data-product_variations');
var variation_data = JSON.parse(variation_data);
@ajmorris
ajmorris / functions.php
Created Apr 18, 2018 — forked from claudiosanches/functions.php
WooCommerce - Change ajax variation threshold
View functions.php
function custom_wc_ajax_variation_threshold( $qty, $product ) {
return 10;
}
add_filter( 'woocommerce_ajax_variation_threshold', 'custom_wc_ajax_variation_threshold', 10, 2 );
@ajmorris
ajmorris / custom-woo-acf-tabs.php
Created Apr 18, 2018
Create custom product details tabs within WooCommerce using an ACF (Advanced Custom Fields) Repeater field.
View custom-woo-acf-tabs.php
<?php
function hwid_load_custom_tab( $tab_key, $tab_info ) {
echo apply_filters( 'the_content', $tab_info['tabContent'] );
}
function hwid_add_content_tabs( $tabs ) {
global $post;
$custom_tabs = get_field( 'tabs', $post->ID );
@ajmorris
ajmorris / acf-fields.php
Last active Apr 18, 2018 — forked from hereswhatidid/acf-fields.php
Create custom product details tabs within WooCommerce using an ACF (Advanced Custom Fields) Repeater field.
View acf-fields.php
<?php
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array (
'key' => 'acf_product_options',
'title' => 'Product Options',
'fields' => array (
array (
'key' => 'acf_product_options_tabbedcontent_label',
'label' => 'Tabbed Content',
@ajmorris
ajmorris / functions.php
Created Mar 28, 2018
Notify admin when a new customer account is created - WooCommerce
View functions.php
<?php // Do not include this if already open!
/**
* Code goes in theme functions.php.
*/
add_action( 'woocommerce_created_customer', 'woocommerce_created_customer_admin_notification' );
function woocommerce_created_customer_admin_notification( $customer_id ) {
wp_send_new_user_notifications( $customer_id, 'admin' );
@ajmorris
ajmorris / functions.php
Created Mar 28, 2018
Add this to create a Facebook and Twitter URL fields to both the WP-Admin and the customer checkout form in WooCommerce.
View functions.php
/**
* Register term fields
*/
add_action( 'init', 'register_vendor_custom_fields' );
function register_vendor_custom_fields() {
add_action( WC_PRODUCT_VENDORS_TAXONOMY . '_add_form_fields', 'add_vendor_custom_fields' );
add_action( WC_PRODUCT_VENDORS_TAXONOMY . '_edit_form_fields', 'edit_vendor_custom_fields', 10 );
add_action( 'edited_' . WC_PRODUCT_VENDORS_TAXONOMY, 'save_vendor_custom_fields' );
add_action( 'created_' . WC_PRODUCT_VENDORS_TAXONOMY, 'save_vendor_custom_fields' );
}
You can’t perform that action at this time.