Skip to content

Instantly share code, notes, and snippets.

@bekarice
bekarice / wc-social-login-all-buttons.php
Last active February 4, 2019 23:17
WooCommerce Social Login Shortcode to Show buttons based on logged in / out users
// Changes button display based on whether user is logged in or not using [wc_social_login_all_buttons] shortcode
function woocommerce_social_login_all_buttons_shortcode( $atts ) {
// Buffer output
ob_start();
// Displays login buttons to non-logged in users with default text from settings
woocommerce_social_login_buttons();
//Displays link account buttons to logged in users
@bekarice
bekarice / wc-social-login-comment-form-buttons.php
Last active February 4, 2019 23:17
Insert WooCommerce Social Login buttons into the comment form
// Adds login buttons to the top of the comment form
function insert_wc_social_login_buttons() {
// Displays login buttons to non-logged in users with default text from settings + redirect back to the comment form
woocommerce_social_login_buttons( home_url( add_query_arg( array() ) ) . '#respond' );
// Optional: include this to display 'link account' buttons to logged in users + redirect back to the comment form
woocommerce_social_login_link_account_buttons( home_url( add_query_arg( array() ) ) . '#respond' );
}
@bekarice
bekarice / wc-social-login-wp-login.php
Last active February 4, 2019 23:17
Add WooCommerce Social Login buttons to the wp-login.php pages
<?php // only copy if needed
/**
* Adds login buttons to the wp-login.php pages
*/
function sv_wc_social_login_add_buttons_wplogin() {
// Displays login buttons to non-logged in users + redirect back to login
woocommerce_social_login_buttons();
}
@bekarice
bekarice / wc-social-login-wplogin-text.php
Last active February 4, 2019 23:16
Change wp-login.php login text
<?php // only copy if need
/**
* Changes the login text from what's set in our WooCommerce settings
* so we're not talking about checkout while logging in.
*
* @param string $login_text the original login text
* @return string updated login text
*/
function sv_wc_social_login_change_text_option( $login_text ) {
@bekarice
bekarice / wc-social-login-text-changes.php
Last active February 4, 2019 23:16
Change social login button text everywhere!
// Changes the login text from what's set in our WooCommerce settings so we're not talking about checkout elsewhere.
function change_social_login_text_option( $login_text ) {
global $pagenow;
// Only modify the text from this option if we're not on the wp-login page
if( 'wp-login.php' === $pagenow ) {
$login_text = __( 'You can also create an account with a social network.', 'WC_Social_Login' );
// Adjust the login text as desired
@bekarice
bekarice / wc-remove-shipping-free-label.php
Last active February 4, 2019 23:16
Remove (Free) after WooCommerce free shipping methods
//Remove (Free) label on cart page for "Shipping and Handling" if cost is $0
function wc_change_cart_shipping_free_label( $label ) {
$label = str_replace( "(Free)", " ", $label );
return $label;
}
add_filter( 'woocommerce_cart_shipping_method_full_label' , 'wc_change_cart_shipping_free_label' );
@bekarice
bekarice / wc-coa-add-attributes.php
Last active August 31, 2022 09:47
Add custom attributes to the WooCommerce Checkout Add-ons form elements
<?php // only copy this line if needed!
/**
* Add attributes to our checkout fields.
*
* @param array $checkout_fields the checkout field data
*/
function wc_add_checkout_add_ons_attributes( $checkout_fields ) {
@bekarice
bekarice / wc-align-cart-buttons.css
Created October 2, 2014 23:44
Align WooCommerce Add to Cart Buttons (MAY CHANGE WITH THEME)
a.added_to_cart.wc-forward {
bottom: 0;
position: absolute;
display: block;
bottom: 0px;
}
.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product {
min-height: 295px !important;
@bekarice
bekarice / wc-admin-new-order-email-change-subject.php
Last active October 20, 2022 11:25
Add customer name to WooCommerce Admin New Order Email subject
<?php // only copy this line if needed!
/**
* Adds customer first and last name to admin new order email subject.
*
* @param string $subject email subject
* @param \WC_Order $order the order object for the email
* @return string updated subject
*/
@bekarice
bekarice / wc-custom-order-status-icon.php
Last active May 13, 2019 17:01
Add WooCommerce custom order status icon
/**
* Adds icons for any custom order statuses
* Tutorial: http://www.skyverge.com/blog/changing-woocommerce-custom-order-status-icons/
**/
add_action( 'wp_print_scripts', 'skyverge_add_custom_order_status_icon' );
function skyverge_add_custom_order_status_icon() {
if( ! is_admin() ) {
return;
}