Skip to content

Instantly share code, notes, and snippets.

View Bradley-D's full-sized avatar
✌️

Bradley Davis Bradley-D

✌️
View GitHub Profile
// 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' );
@Bradley-D
Bradley-D / Generate Public Key and Convert to PEMs
Last active August 31, 2022 23:47
This will help generate a private pem and then you can extract the public key and save it
// This will generate a private PEM
openssl genrsa -out PATH-LOCATION/file_name_private.pem 1024
// Now extract public key from the private pem and save it to a file
openssl rsa -in PATH-LOCATION/file_name_private.pem -pubout > PATH-LOCATION/file_name_public.pem
// Gravity Forms Custom Addresses (Australia)
// Credit: The Web Princess - http://thewebprincess.com/
function australian_address( $address_types, $form_id ) {
$address_types['australia'] = array(
'label' => 'Australia', //labels the dropdown
'country' => 'Australia', //sets Australia as default country
'zip_label' => 'Post Code', //what it says
'state_label' => 'State', //as above
'states' => array(
function bd_woocommerce_quantity_input_args( $args, $product ) {
$args['input_value'] = 1; // Starting value
$args['max_value'] = 800; // Maximum value
$args['min_value'] = 1; // Minimum value
$args['step'] = 1; // Quantity steps
return $args;
}
add_filter( 'woocommerce_quantity_input_args', 'bd_woocommerce_quantity_input_args', 10, 2 );
// Add the div to wrap the image on the archive pages
add_action( 'woocommerce_before_shop_loop_item_title', create_function('', 'echo "<div class=\"archive-img-wrap\">";'), 5, 2);
add_action( 'woocommerce_before_shop_loop_item_title',create_function('', 'echo "</div>";'), 12, 2);
// If there is sub categories on the archive page add a wrap around their images as well
add_action( 'woocommerce_before_subcategory_title', create_function( '', 'echo "<div class=\"sub-archive-img-wrapper\">";'), 5, 2 );
add_action( 'woocommerce_before_subcategory_title', create_function( '', 'echo "</div>";' ), 12, 2 );
@Bradley-D
Bradley-D / HTML: Menu for a hero area with animation
Last active November 2, 2018 06:23
HTML: Menu for a hero area with animation
I needed to add a "menu" to a hero area on a page so I thought this would be a good boilerplate for another time.
@Bradley-D
Bradley-D / Add Security to target _blank
Last active May 21, 2018 07:08
jQuery: Target Blank Security
$('a').each(function () {
if ($(this).attr('target') == '_blank') {
if ($(this).attr('rel')) {
this.rel += ' noopener noreferrer';
} else {
$('a').attr('rel', 'noopener noreferrer');
}
};
});
@Bradley-D
Bradley-D / WooCommerce: Gallery Slider Navigation Controls
Last active May 3, 2018 06:42
WooCommerce: Gallery Slider Navigation Controls
// Add text before regular price and sale price
function bd_rrp_sale_price_html( $price, $product ) {
if ( $product->is_on_sale() ) :
$has_sale_text = array(
'<del>' => '<del>RRP: ',
'<ins>' => '<br>Sale Price: <ins>'
);
$return_string = str_replace(array_keys( $has_sale_text ), array_values( $has_sale_text ), $price);
// Replace WooCommerce product placeholder
function _custom_woocommerce_placeholder_img_src( $src ) {
$src = trailingslashit( get_template_directory_uri() ) . 'includes/images/placeholder.jpg'; // Change to required path and name
return $src;
}
add_filter( 'woocommerce_placeholder_img_src', '_custom_woocommerce_placeholder_img_src' );