Skip to content

Instantly share code, notes, and snippets.

View sarangs07's full-sized avatar

Sarang Shahane sarangs07

  • Pune, Maharashtra.
View GitHub Profile
/* Display the text on specific checkout pages */
add_action( 'woocommerce_checkout_before_order_review', 'mi_add_text_after_your_order_heading' );
function mi_add_text_after_your_order_heading(){
global $post;
switch ( $post->ID ) {
case 105: // Add your checkout page id on which you want to display the custom text
$html_code = '
<div class="hello">for first checkout page</div>
@sarangs07
sarangs07 / functions.php
Last active December 13, 2019 03:48
Change the coupon field's & button text on the CartFlows pages.
/* Coupon field text change filter */
add_filter( 'cartflows_custom_coupon_text', 'be_change_coupon_fields_text' );
// Callback function.
function be_change_coupon_fields_text( $coupon_text ){
$coupon_text['field_text'] = 'textbox_placeholder_text'; // Replace your string here.
$coupon_text['button_text'] = 'Apply_button_test'; // Replace your string here.
@sarangs07
sarangs07 / functions.php
Created December 17, 2019 04:23
Change the Text & URL of the ADD TO CART button on the shop page for any theme
// Change the Text & URL of the ADD TO CART button on the shop page
add_filter( 'woocommerce_loop_add_to_cart_link', 'an_replacing_add_to_cart_button_link', 10, 2 );
function an_replacing_add_to_cart_button_link( $button, $product ) {
// Get the current product id.
$this_product_id = $product->get_id();
// add the condition cases for the product which you want to set the custom URL.
switch ($this_product_id) {
@sarangs07
sarangs07 / functions.php
Created December 17, 2019 05:57
Remove the add to cart message/notice from the CartFlows checkout page only
/* Remove the add to cart message/notice from the CartFlows checkout page only */
function remove_added_to_cart_notice()
{
// Get all notices.
$notices = WC()->session->get('wc_notices', array());
// Check array is blank or not. Means any notices are present or not.
if( is_array( $notices ) && !empty( $notices ) ){
// Search for only sucess message.
@sarangs07
sarangs07 / functions.php
Last active July 22, 2020 08:52
Redirect to the checkout page instead of cart page. Works with any theme.
/*
* How to add the custome code.
*
* Please follow below instructions:
* 1. Copy the below code.
* 2. Open your child theme's functions.php file.
* 3. Paste the copied code at the very bottom of it & save the file OR upload it on your server/hosting.
*/
@sarangs07
sarangs07 / functions.php
Last active April 21, 2020 12:35
Modify the CPT's arguments. Works with all the themes & plugins.
/*
* How to add the custome code.
*
* Please follow below instructions:
* 1. Copy the below code.
* 2. Open your child theme's functions.php file.
* 3. Paste the copied code at the very bottom of it & save the file OR upload it on your server/hosting.
*/
@sarangs07
sarangs07 / functions.php
Last active July 27, 2023 08:45
Show sale & regular price on the checkout page
/*
* How to add the custome code.
*
* Please follow below instructions:
* 1. Copy the below code.
* 2. Open your child theme's functions.php file.
* 3. Paste the copied code at the very bottom of it & save the file OR upload it on your server/hosting.
*/
@sarangs07
sarangs07 / functions.php
Created December 24, 2019 15:05
Autofill checkout fields from user data provided from the URL
/* Autofill checkout fields from user data provided from the URL*/
add_filter( 'woocommerce_checkout_fields' , 'mi_prefill_billing_fields' );
function mi_prefill_billing_fields ( $address_fields ) {
// Get the data from the URL
if ( isset( $_GET['fname'] ) || isset( $_GET['lname'] ) || isset( $_GET['email'] ) )
{
// wp_die();
$fname = isset( $_GET['fname'] ) ? esc_attr( $_GET['fname'] ) : '';
@sarangs07
sarangs07 / functions.php
Created December 26, 2019 07:39
Remove extra html Jupiter Theme conflict
/* Remove extra html Jupiter Theme conflict */
add_action( 'wp', 'remove_jupiter_conflict_actions' );
function remove_jupiter_conflict_actions(){
global $post;
$post_type = get_post_type();
$page_template = get_post_meta( $post->ID, '_wp_page_template', true );
@sarangs07
sarangs07 / functions.php
Last active January 2, 2020 05:45
Change the place order button on checkout page.
/* Change the place order button on checkout page. */
add_filter( 'gettext', 'show_custom_button_text', 20, 3 );
function show_custom_button_text( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Proceed to PayPal' : // you can remove this if you don't want to change the button text for PayPal
$translated_text = __( 'Your new Paypal button text here', 'woocommerce' );
break;
case 'Place order' : // This text will change for all other firstly with the COD option and for those payment gateways who don't change the text.
$translated_text = __( 'Your new COD button text here', 'woocommerce' );
break;