Skip to content

Instantly share code, notes, and snippets.

View wbcomdev's full-sized avatar

Wbcom Dev wbcomdev

View GitHub Profile
/**
* Remove breadcrumbs in Woo developed themes.
*/
function wb_woo_remove_woo_breadcrumbs() {
remove_action( 'woo_main_before', 'woo_display_breadcrumbs', 10 );
}
add_action( 'init', 'wb_woo_remove_woo_breadcrumbs' );
/**
* Remove breadcrumbs on specific pages.
*/
function wb_wc_remove_woo_wc_breadcrumbs() {
if ( is_woocommerce() || is_cart() || is_checkout() ) {
remove_action( 'woo_main_before', 'woo_display_breadcrumbs', 10 );
}
}
add_action( 'init', 'wb_wc_remove_woo_wc_breadcrumbs' );
/**
* Add a message above the login / register form on my-account page.
*/
function wb_login_message() {
if ( get_option( 'woocommerce_enable_myaccount_registration' ) == 'yes' ) {
?>
<div class="woocommerce-info">
<p><?php esc_html_e( 'Returning customers login. New users register for next time so you can:' ); ?></p>
<ul>
<li><?php esc_html_e( 'View your order history' ); ?></li>
/**
* Apply a coupon for minimum cart total.
*/
function wb_add_coupon_notice() {
$cart_total = WC()->cart->get_subtotal();
$minimum_amount = 50;
$currency_code = get_woocommerce_currency();
wc_clear_notices();
/**
* Add Custom currency name and currency symbol.
*/
function wb_add_my_currency( $currencies ) {
$currencies['ABC'] = __( 'Currency name', 'woocommerce' );
return $currencies;
}
add_filter( 'woocommerce_currencies', 'wb_add_my_currency' );
/**
/**
* Send an email each time an order with coupon(s) is completed.
* The email contains coupon(s) used during checkout process.
*/
function wb_woo_email_order_coupons( $order_id ) {
$order = new WC_Order( $order_id );
if ( $order->get_used_coupons() ) {
$to = 'youremail@yourcompany.com';
/*
* goes in theme functions.php or a custom plugin.
*
* Subject filters:
* woocommerce_email_subject_new_order
* woocommerce_email_subject_customer_processing_order
* woocommerce_email_subject_customer_completed_order
* woocommerce_email_subject_customer_invoice
* woocommerce_email_subject_customer_note
* woocommerce_email_subject_low_stock
/**
* Adjust the quantity input values.
*/
function wb_woocommerce_quantity_input_args( $args, $product ) {
if ( is_singular( 'product' ) ) {
$args['input_value'] = 2; // Starting value (we only want to affect product pages, not cart).
}
$args['max_value'] = 80; // Maximum value.
$args['min_value'] = 2; // Minimum value.
$args['step'] = 2; // Quantity steps.
<?php
/**
* Plugin Name: WooCommerce <enter name> Gateway
* Plugin URI: https://wbcomdesigns.com/
* Description: Extends WooCommerce with an <enter name> gateway.
* Version: 1.0
* Author: Wbcomdesigns
* Author URI: https://wbcomdesigns.com/
*/
function wb_woocommerce_gateway_name_init() {
/**
* Add a new country to countries list.
*/
function wb_add_my_country( $countries ) {
$new_countries = array(
'NIRE' => __( 'Northern Ireland', 'woocommerce' ),
);
return array_merge( $countries, $new_countries );
}