I'm trying to translate a word on the WooCommerce checkout page.
My website is in the Dutch language, but they translated it poorly, so I want to use a different word.
What needs to be translated
It concerns the following line:
"Totaal €469,38 (Inclusief €79,38 Belasting)"
In English this says:
"Total €469,38 (Includes €79,38 tax)"
It's the line that sums up the total amount of the order. And I want to translate the word 'Belasting' to 'BTW'.
What I've tried
Checked out settings in WooCommerce
Installed the plugin Loco translator
Searched for the word with FTP (Adobe Dreamweaver)
As I couldn't find the word 'Belasting' anywhere, I did find the php-file with the element of the line.
This I found in the PHP-document wc-cart-functions.php:
if ( ! empty( $tax_string_array ) ) {
$value .= '<small class="includes_tax">' . sprintf( __( '(Includes %s)', 'woocommerce' ), implode( ', ', $tax_string_array ) ) . '</small>';
}
And this is how the HTML part looks like:
<small class="includes_tax">
(inclusief
<span class="amount">€79,38</span>
Belasting)
</small>
My Question
I presume it does print the word 'Belasting' with the '%s' variable. However I am unable to find the content for that variable anywhere.
So can anybody help me out by finding how to translate this word?
Thanks for reading and I'd appreciate the help.
You can try using the gettext filter
Example
function my_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Related Products' :
$translated_text = __( 'Check out these related products', 'woocommerce' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'my_text_strings', 20, 3 );
WooCommerce uses gettext for translations, as described here there are several methods of updating the translation, the easies of which is editing the file in woocommerce/i18n/languages/
The "Includes" part is translate-supported. i.e. you just need to add it to your translation file:
The translation file is in my case (danish): "../wp-content/languages/plugins/woocommerce-da_DK.po"
Open the file in your texteditor, e.g. Notepad++ and add these lines:
#: includes/class-wc-order.php:40 includes/wc-cart-functions.php:246
msgid "(Includes %s)"
msgstr "(Inkluderer %s)"
Now you need to compile the PO file to an MO file and you can use Poedit.
Just open the PO file and save it, it will create a new MO file that you can upload and replace the current MO file (path: "../wp-content/languages/plugins/")
So fare so good!
In regards to the "Tax" part. This is controlled in the admin module:
Related
I'm curently struggling with a problem. I have an XML that is having 4 zeros after decimal in product dimensions and I need to remove the trailing zeros after the import...
Any ideas?
You can try running each value through a custom PHP function which will remove the trailing zeros. During the import replace the value (e.g. {price[0]}) with something like this:
[strip_trailing_zeroes_from_price({price[0]})]
Also write the actual code and insert into the Function Editor on the Edit Import page:
function strip_trailing_zeroes_from_price( $price = null ) {
if ( !empty( $price ) ) {
// strip trailing zeroes from price
}
return $price;
}
Guide: https://www.wpallimport.com/documentation/developers/custom-code/inline-php/
I'm using WC Ajax Product Filter for filtering options .
Unfortunately the price range is showing :
Min Price: ₹NaN
Max Price: ₹NaN
The actual price is not displaying. Please help me out . I'm new to woocommerce .
The issue found out !
The minimum and maximum price range difference for the products was very less. For example - minimum was $65 and maximum was $66, that was the issue.
I've found a temporary solution, edit the plugin file: wcapf.php :you can find this in the root of the plugin directory: wc-ajax-product-filter
Now search for the code: getPriceRange
This occurs in 2 spots around line #467 and line #773
On both 2 spots you see an if statement below which uses sizeof() function.
There seems to be some sort of issue with this.
I have fixed the issues of NaN by commenting out the entire if and else statement that uses the sizeof() function, see below code for example.
It's not the best solution, but well it works, untill update.. I will post this to plugin creator as well.
#469:
//if (sizeof($unfiltered_price_range) === 2) {
#522:
//}
#781:
//if (sizeof($price_range) > 2) {
#840:
//} else {
// empty array
// return array();
//}
Solved it this way.
Edit widget-price-filter.php file.
It's in the folder /ajax-product-filter/widgets/
Replace the following code in line 125:
<span class="wcapf-slider-value" id="wcapf-noui-slider-value-min"></span> - <span class="wcapf-slider-value" id="wcapf-noui-slider-value-max"></span>
By:
if ($min_val!=0 && $max_val!=0 ) {
echo '<span class="wcapf-slider-value" id="wcapf-noui-slider-value-min"></span> - <span class="wcapf-slider-value" id="wcapf-noui-slider-value-max"></span>';
} else{ echo '-';}?>
It will replace the NaN values bellow the slider by (-), just change the last line if you want another text there.
Wordpress Redirects
My client has a WP website with a very bad permalinks structure and few hundreds "product" pages that they created as simple posts with bunch of HTML.
For example:
http://www.website.com/article/sony-tv-42-inch
http://www.website.com/article/iphone-5-2-black
http://www.website.com/article/samsung-dvd-player-12455
I am creating a new site from scratch and planning to use custom post types for Products section and organize URLS like:
http://www.website.com/product/sony/tv-42-inch
http://www.website.com/product/apple/iphone-5-black
http://www.website.com/product/samsung/dvd-player-12455
Since he doesnt want to lose any traffic or SEO ratings, i was wondering what would be the simplest solution for htaccess redirect for few hundred posts?
If he only had dozen of them, i could do it manually, but few hundreds...
Also, bare in mind that this is clean WP install with a theme built from scratch (i am working locally and most likely will be importing products via CSV file) so i cant just change the permalinks structure on production website.
Any help would be appreciated
It'd be fairly easy for you to re-write from
http://www.website.com/product/sony-tv-42-inch
to
http://www.website.com/product/sony-tv-42-inch
but that extra / is going to present a problem.
As mentioned by some others you certainly want a 301 for SEO purposes, so here is what I would do.
Step 1 - Get current URLS:
Get a list of all current post permalinks. This SQL query for MySQL by David George should do the trick.
SELECT wpp.post_title,
wpp.guid,
wpp.post_date,
CONCAT
(
wpo_su.option_value,
REPLACE
(
REPLACE
(
REPLACE
(
REPLACE
(
wpo.option_value,
'%year%',
date_format(wpp.post_date,'%Y')
),
'%monthnum%',
date_format(wpp.post_date, '%m')
),
'%day%',
date_format(wpp.post_date, '%d')
),
'%postname%',
wpp.post_name
)
) AS permalink
FROM wp_posts wpp
JOIN wp_options wpo
ON wpo.option_name = 'permalink_structure'
AND wpo.blog_id = 0
JOIN wp_options wpo_su
ON wpo_su.option_name = 'siteurl'
AND wpo_su.blog_id = wpo.blog_id
WHERE wpp.post_type = 'post'
AND wpp.post_status = 'publish'
ORDER BY wpp.post_date DESC
Step 2 - Save it for later:
Now that you have that list dump it into an Excel column for later.
Step 3 - Format it for PHP:
Take all the URLs and dump them into Notepad++ or equivalent. On windows hit cntrl+H to bring up the find/replace function. Make sure to select 'Search Mode' -> 'Extended'
For "Find What" you should put in \r\n and for 'Replace With' you should put in , and hit 'Replace All'.
You should now have a list of all your URLs separated only by a comma.
Step 4 - Create a PHP File:
Create a new PHP file and set:
<?php
$urlString = "http://www.urlsample1.com/article/sony-thing-and-stuff, http://www.urlsample1.com/article/warner-brothers-stuff";
//this will replace the word article with the word product
$newstring = str_replace("article", "product", $urlString);
//turns string into array
$myArray = explode(',', $newstring);
//loops through array to find first case of - and turn it to a /
for ($i = 0; $i < count($myArray); ++$i) {
$haystack = $myArray[$i];
$needle = "-";
$replace = "/";
$pos = strpos($haystack, $needle);
if ($pos !== false) {
$finalstring = substr_replace($haystack, $replace, $pos, strlen($needle));
}
//removes common url elements
$newShort = str_replace("http://www.urlsample1.com", "", $finalstring);
$oldShort = str_replace("http://www.urlsample1.com/product", "/article", $myArray[$i]);
//prints out the old and new url in .htaccess format
print("Redirect 301 " . $oldShort . " " . $newShort . "</br>");
};
?>
Step 5 - .Htaccess
Your output from above should look like:
Redirect 301 /product/sony-thing-and-stuff /product/sony/thing-and-stuff
Redirect 301 /product/warner-brothers-stuff /product/warner/brothers-stuff
and can be put into the .htaccess file.
Note: This method may become slow with Apache and isn't preferable but it is the quickest way I can think of to get your client up and running on the new situation.
For SEO, i suggest you use 301 - redirect in your .htaccess
You can use regexp for redirect.
Example:
RewriteEngine on
RewriteRule ^/users/(.*)$ http://www.example.com/profiles/$1 [R=301,L]
In my Wordpress RSS Feed : http://hellobiz.fr/feed/
Apostrophes are replaced by "’" in
I need to use the true character: '
Do you have solution please ?
Thank you !
I actually fixed the problem, although it might not be the most correct/elegant solution.
In wp-includes/feed-functions.php
function get_the_title_rss() {
$title = get_the_title();
// $title = apply_filters('the_title', $title);
$title = apply_filters('the_title_rss', $title);
return $title;
Commenting out that line changed the offending "right single quotation mark" (aka ’) into the straight up and down apostrophe that apparently magpie can handle no problem.
Before I started digging in the code I was playing with the encoding, and was in for a HECK of a surprise when I changed it to UTF-16.
I am trying to learn how to create my own module and I am stuck. I created text.module, text.install and text.info . It's just a basic module for inputing text.
So now I have the next scenario I input the text in textbox, it saves to a table in the database i can display it into a table like in this:
http://img33.imageshack.us/img33/5815/textyi.jpg
now my question is can you and how can you use function view so that in the picture "ttt" becomes a link so that you can see the title and text "ttt" ?
EDIT :
I figure out something i just need this :
in table I have 3 columns (test_id, title, text)
Now i use
$result = db_query("select title,text from {text} ");
now how can I turn title into a link . Let say that in row 1 col1 of title it stands house. How can i turn house into a link. Do i need to do sometning like this
$result= db_query ("select n.title, n.text form {text} n where n.title = :title", array (":title" => ???? ))
I think this is what you are looking for
<?php
l(t('Link text'), 'about-us', array('attributes' => array('class' => 'about-link')));
?>
http://api.drupal.org/api/drupal/includes%21common.inc/function/l/7 might help u..