Wednesday 27 July 2016

How to Rename Coupon Code fields with WooCommerce, WordPress?


Just renaming the coupon field to something else can likewise diminish the quantity of clients that leave your site amid checkout to discover coupon codes. Clients that as of now have the code will comprehend what name to search for whatever length of time that you're steady. For instance, on the off chance that you email out "Offer Codes" or "Promo Codes", then clients will search for this field, yet those without coupons won't get occupied by the words "coupon" or 'rebate'.

Simply following the steps of code changing for rename the coupon code fields.

Add following code in "functions.php" file.


<?php
/************************************************
 * rename the coupon field on the cart page
 ************************************************/
function woocommerce_rename_coupon_field_on_cart( $translated_text, $text, $text_domain ) {
// bail if not modifying frontend woocommerce text
if ( is_admin() || 'woocommerce' !== $text_domain ) {
return $translated_text;
}
if ( 'Apply Coupon' === $text ) {
$translated_text = 'Apply Promo Code';
}
return $translated_text;
}
add_filter( 'gettext', 'woocommerce_rename_coupon_field_on_cart', 10, 3 );



/************************************************
 * rename the "Have a Coupon?" message on the checkout page
 ************************************************/
function woocommerce_rename_coupon_message_on_checkout() {
return 'Have a Promo Code?' . ' <a href="#" class="showcoupon">' . __( 'Click here to enter your code', 'woocommerce' ) . '</a>';
}
add_filter( 'woocommerce_checkout_coupon_message', 'woocommerce_rename_coupon_message_on_checkout' );
// rename the coupon field on the checkout page
function woocommerce_rename_coupon_field_on_checkout( $translated_text, $text, $text_domain ) {
// bail if not modifying frontend woocommerce text
if ( is_admin() || 'woocommerce' !== $text_domain ) {
return $translated_text;
}
if ( 'Coupon code' === $text ) {
$translated_text = 'Promo Code';

} elseif ( 'Apply Coupon' === $text ) {
$translated_text = 'Apply Promo Code';
}
return $translated_text;
}
add_filter( 'gettext', 'woocommerce_rename_coupon_field_on_checkout', 10, 3 );

?>

Above bold text place do rename as you need.



For more Interesting, Useful Article & codes visit IT New Code.

Saturday 23 July 2016

Learn about left join query

The LEFT JOIN keyword returns all rows from the left table (table1), with the matching rows in the right table (table2). The result is NULL in the right side when there is no match.

In some databases LEFT JOIN is called LEFT OUTER JOIN.

Query:-

SELECT column_name(s)
FROM table1
LEFT JOIN table2
ON table1.column_name=table2.column_name;

OR

SELECT column_name(s)
FROM table1
LEFT OUTER JOIN table2
ON table1.column_name=table2.column_name;

Now,Join Query with objects:-

Query 1 simple
------------------

select t.*,c.* from time as t  LEFT JOIN country as c ON t.countryId=c.id 
Query 2 long 
------------------
select t.*,c.*,st.*,d.* from time as t  LEFT JOIN country as c ON t.countryId=c.id LEFT JOIN  states as st ON t.stateId=st.id LEFT JOIN date as d ON t.dateId=d.id 
Query 3 in order
--------------------
select t.*,c.*,st.*,d.* from time as t  LEFT JOIN country as c ON t.countryId=c.id LEFT JOIN  states as st ON t.stateId=st.id LEFT JOIN date as d ON t.dateId=d.id  ORDER BY name
Query 4 conditional
--------------------
select t.*,c.*,st.*,d.* from time as t  LEFT JOIN country as c ON t.countryId=c.id LEFT JOIN  states as st ON t.stateId=st.id LEFT JOIN date as d ON t.dateId=d.id  ORDER BY name where usr_id=$id



For more Interesting, Useful Article & codes visit IT New Code.

 

Copyright @ 2016 IT New Code | Developing Code | Designing Code.

Designed by: Ankit Shah