I want to add a dot with currency code, for example, my currency code is RS then I want this format (RS.) then the amount will be displayed.
I want this formate RS. 300 With my amount 300. kindly help me...
IN woocommerce I try many currency positions. for example in woocommerce they give us
left
right
left with space
right with space
But I also want "left with dot" and "right with dot".
how can I customize for this?
Is this not the decimal seperator? Maybe add this to . and then set the number of decimals to whatever you need
For This, You Must add a Custom Currency Symbol Try Adding bellow Code to your Functions.php in your child theme
/**
* Custom currency and currency symbol
*/
add_filter( 'woocommerce_currencies', 'add_my_currency' );
function add_my_currency( $currencies ) {
$currencies['Rs.'] = __( 'Pakistani Rupees', 'woocommerce' );
return $currencies;
}
add_filter('woocommerce_currency_symbol', 'add_my_currency_symbol', 10, 2);
function add_my_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'Rs.': $currency_symbol = 'Rs.'; break;
}
return $currency_symbol;
}
Related
I'm trying to set / show a label for the billing_address_2 field on the Woocommerce checkout page, but can't find a way to do this. Does anyone know a solution?
The code below (which works fine on other fields) does not do the job.
add_filter( 'woocommerce_checkout_fields' , 'custom_rename_wc_checkout_fields' );
function custom_rename_wc_checkout_fields( $fields ) {
$fields['billing']['billing_address_2']['label'] = 'Building number';
return $fields;
}
Updating this question with an answer for the sake of future readers.
As of WooCommerce 3.5.1, commit 87054ece9a4c05db72e139730ed1764c63fab635 adds the 'screen-reader-text' label_class to both Billing & Shipping Address 2 fields for accessibility purposes as per Issue #21182. This class will keep the label hidden unless it is also changed (e.g. make it blank, like the Address 1 field).
Here's how I updated my functions.php to get the billing/shipping_address_2 labels back (I'm using the separate billing/shipping filters as I have made changes to other fields I didn't include in the code for brevity).
// Billing Fields.
add_filter( 'woocommerce_billing_fields', 'custom_woocommerce_billing_fields' );
function custom_woocommerce_billing_fields( $fields ) {
$fields['billing_address_2']['label'] = 'Address 2';
$fields['billing_address_2']['label_class'] = '';
return $fields;
}
// Shipping Fields.
add_filter( 'woocommerce_shipping_fields', 'custom_woocommerce_shipping_fields' );
function custom_woocommerce_shipping_fields( $fields ) {
$fields['shipping_address_2']['label'] = 'Address 2';
$fields['shipping_address_2']['label_class'] = '';
return $fields;
}
I am beginner on WordPress.
I want to get two things done on my WordPress site.
No 1: I want to make checkbox just with the word "Total"
No:2: When user would hit the checkbox, the quantity selector
must be disabled or diapered and only 1 item must be added into cart.
Please help me out, how can i do that.
Thanks in advance
if you want that customer will order only one quantity of product then you can do one thing is using woo-commerce
=> in product menu select add new product or edit nay product and GOTO product data below Editor and select inventory tab from that.
=> and select sold individually checkbox so this allow only one quantity for sell.
so you don't need to write any code for that.
and let me know if you want to write code for that.
I Hope this will work for you perfectly.
Thanks.
Edited :-
May i hope you got your answer this time
/**# Remove in all product type*/
function custom_remove_all_quantity_fields( $return, $product ) {return true;}
add_filter( 'woocommerce_is_sold_individually','custom_remove_all_quantity_fields', 10, 2 );
===================================
Edit for particular product
/**
* #Hide from different product type group
*/
add_filter( 'woocommerce_is_sold_individually', 'baztro_wc_remove_all_quantity_fields', 10, 2 );
function baztro_wc_remove_all_quantity_fields( $return, $product ) {
switch ( $product->product_type ) :
case "variable":
return true;
break;
case "grouped":
return true;
break;
case "external":
return true;
break;
default: // simple product type
return true;
break;
endswitch;
}
Here you go:
function add_checkbox_before_addtocart_quantity() {
?>
<div style="display:block; clear:both;"><input type="checkbox" id="totalcheck" name="subscribe" value="totalcheck"><label for="totalcheck"> Total</label></div>
<script>
(function( $ ) {
$('input#totalcheck').change(function () {
if(this.checked) {
// Set quantity to 1
$("input.input-text.qty.text").val("1");
// Hide quantity box
$(".quantity").hide();
}else{
// Show quantity box if total is not checked
$(".quantity").show();
}
});
})( jQuery );
</script>
<?php
};
add_action( 'woocommerce_before_add_to_cart_quantity', 'add_checkbox_before_addtocart_quantity', 10 );
How to wrap woocommerce currency symbol in span?
The question pretty much sums it all up. I want to style woocommerce currency symbol individually and i can't do it since it is outputted as text content with the price.
Please if anyone can help me, I would vary much appreciate it.
Thank you.
I figured it out :)
add_filter('woocommerce_currency_symbol', 'change_existing_currency_symbol', 10, 2);
function change_existing_currency_symbol( $currency_symbol, $currency ) {
$currency_symbol = '<span>' . $currency_symbol . '</span>';
return $currency_symbol;
}
This way you can add custom currency in woocommerce :
add_filter('woocommerce_currencies', 'add_custom_currency');
function add_custom_currency($currencies) {
$currencies["SPAN"] = 'Span Euro';
return $currencies;
}
add_filter('woocommerce_currency_symbol', 'add_custom_currency_symbol', 10, 2);
function add_custom_currency_symbol($currency_symbol, $currency) {
switch ($currency) {
case 'SPAN': $currency_symbol = 'Sp';
break;
}
return $currency_symbol;
}
Here 'Sp' is the currency shown on your website.
I am developing a new woocommerce site, and faced a new issue that I have not dealed with in other shops. I need to change the currency symbol to something else than the standard. In my country it's DKK. And my custom text should be "DKK / month" but only in the cart(product loop overview), not in total calculation(checkout section), because, for example, freight is not / month and totals is not either.
Following code is working great everywhere on the page, but it needs to be only in the cart listing/loop pr. product, and also btw in the reciept product listing.
add_filter('woocommerce_currency_symbol', 'change_existing_currency_symbol', 10, 2);
function change_existing_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'DKK': $currency_symbol = 'kr. <span class="paymentType">/ month</span>'; break;
}
return $currency_symbol;
}
How do i change that to only appear at cart product loop?
I have tried with:
if(is_cart()){
add_filter('woocommerce_currency_symbol', 'change_existing_currency_symbol', 10, 2);
function change_existing_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'DKK': $currency_symbol = 'kr. <span class="paymentType">/ month</span>'; break;
}
return $currency_symbol;
}
}
But is not working, and I am not sure that's it is the right approach.
Suggestions? :-)
Instead of dealing with above I ended up manually typing / month in the various template files (not core files) where the price was defined. Hope this will help someone else :)
Geeks and code Gods,
I am having an issue with my wordpress code. I have added 3 extra columns to the dashboard's pages screen.
One of which displays the custom field 'scode'. The scode custom field holds the cart66 shortcode which adds an 'add cart' button to the page it is assigned to.
The shortcode looks like this:
[add_to_cart item="HD-NL-7010"]
Each page has a different shortcode.
Every shortcode is the same length, 31 characters long.
However Id prefer not to show the whole shortcode in the column, only the product code *HD-NL-7010* section of the code.
Is it possible to hide the first 19 and last 2 characters. Basically removing [add_to_cart item=" and "]
Below is the code I added to function.php to add the custom columns to the pages table:
function test_modify_post_table( $column ) {
$column['scode'] = 'Product Code';
$column['Price'] = 'Price';
$column['Product_Image'] = 'Image';
return $column;
}
add_filter( 'manage_pages_columns', 'test_modify_post_table' );
function test_modify_post_table_row( $column_name, $post_id ) {
$custom_fields = get_post_custom( $post_id );
switch ($column_name) {
case 'scode' :
echo $custom_fields['scode'][0];
break;
case 'Price' :
echo '£' . $custom_fields['Price'][0];
break;
case 'Product_Image' :
echo $custom_fields['Product_Image'][0];
break;
default:
}
}
add_filter( 'manage_pages_custom_column', 'test_modify_post_table_row', 10, 2 );
Thank you for reading this post. Any help would be greatly appreciated.
P.S. I'm going to ask this in another post but does anyone know how to get the Product_Image to show as an image in the page column rather than the image attachment ID?
I might be misunderstanding, does PHP's substr help? Something like:
case 'scode' :
echo substr( $custom_fields['scode'][0], 19, 10 );
break;
For what it's worth, I think I'd store just the code (HD-NL-7010) in the custom field, rather than the shortcode code, then apply the shortcode where needed (with do_shortcode).