The b2bking plugin has helped me alot with my shop. One of its features in that it can display both a wholesale and a retail price.
My problem is that we are a swedish shop and I would like it to say "ÅF-pris" and "RRP" instead of what is outputs by default.
I've tried modifying the code inside the plugin. It works but I know that it will stop working as soon as I update the plugin. This is why I want to do it with filter hooks provided by the plugin.
What I've tried (I am kinda new to PHP)
add_filter('b2bking_filter_wholesale_price_final', 'alex_translate_price_text');
function alex_translate_price_text($text_retail_price, $text_final_price){
$text_retail_price = 'test_RRP: ';
return $text_retail_price;
$text_final_price = 'test_åf-pris: ';
return $text_final_price;
}
in the plugin, hook looks like this:
$price = apply_filters('b2bking_filter_wholesale_price_final', $price, $text_retail_price, $retail_price, $text_final_price, $b2b_price_price, $product_id);
My thought process is that I want to change the variables "$text_retail_price" and "$text_final_price" to "ÅF-pris" and "RRP" as right now they contain "Retail price" and "Wholesale price".
We're the developers of the plugin, glad to hear it's been useful to you,
There's now a setting where you can change these directly via B2BKing -> Settings -> Language & Text.
Related
I've got the hook set up for 'woocommerce_hidden_order_itemmeta' but it is not being triggered during a purchase. My code is below. Note, the code is simplified with the function simply logging a message so I can see if it is being triggered.
function filter_woocommerce_hidden_order_itemmeta( $array ) {
error_log("GOT TO filter_woocommerce_hidden_order_itemmeta()");
return $array;
}
add_filter( 'woocommerce_hidden_order_itemmeta', 'filter_woocommerce_hidden_order_itemmeta', 10, 1 );
I have configured many other WooCommerce hooks and they are being triggered correctly. Is there something special about 'woocommerce_hidden_order_itemmeta'? Does something have to be configured elsewhere before this hook is triggered?
Thanks in advance for any help!!
Cheers!!
I had this same problem recently. Still trying to figure out what's going on, but I can sure you that, if you put this code at functions.php of theme, there's a great chance to get this specific hook to work.
However, this problem affects not only woocommerce_hidden_order_itemmeta hooks, but other ones like woocommerce_after_order_itemmeta, and probably everything suffixed by _order_itemmeta (only a personal guess in this last part)
Obs: Before trying this workaround above, certify yourself that you're using this hook on Order Details Metabox. I think this is the only place where these hooks like *_order_itemmeta are supposed to get work, anyway.
I'm trying to adjust the product feed in an older Magento 1 shop with the add-on "Simple Google Shopping" so that the shipping costs are returned depending on the product weight.
This Plugin is php-based: User Guide
This is the snippet of code that doesn't work for me. Do you have any idea what the problem could be?
<g:price>
<?
if( {weight} >= 31.5)
{return 79.90;}
else
{return 4.00;}
?>
</g:price>
I've found the solution:
The problem was that, contrary to the user guide, the variable call has to look like this:
$weight and not '{weight}' or '$product->weight'
Tl;dr: I want to use similar functionality in WC shortcodes but within the WC shop page.
I have many custom Woocommerce shortcodes I have created. I use them throughout non-shop pages.
E.g:
function displayProductIngredients($item) {
$product = wc_get_product($item['id']);
return $product->get_attribute( 'ingredients' );
}
add_shortcode('product_ingredients', 'displayProductIngredients');
I would like to use them in the archive-product.php page too.
E.g. in the example this shortcode adds the content of the "ingredients" attribute. How can the same be added for each new product added?
Is this just a case of moving around some of the php? If so, how might it look?
Thank you very much.
How can I place a default text (hashtag) in the Custom Message?
The textarea is (located in line 643) under jetpack/modules/publicize/ui.php
I tried to put the text in front of $title in various ways, like:
<?php echo "#myhashtag $title"; ?>
or
<?php echo '#myhashtag '.$title; ?>
but it just echoes the text, not the $title.
Any ideas will be greatly appreciated.
You can use the approach of this Wordpress plugin i made (Publicize With Hashtags), which does exactly that. It basically use and action trigger bound to the 'save_post' native event.
If you want to develop your own one you can have a look at my Source Code on the project's GitHub page or in this installation & usage guide I wrote about it.
You can add a filter, like so, to your theme's functions.php or a site-specific plugin:
add_filter( 'wpas_default_prefix', 'add_default_publicize_hashtag_prefix', 10, 4 );
function add_default_publicize_hashtag_prefix() {
$default_tags = '#yourhastaghere ';
return $default_tags;
}
This will add your default hashtag before your title without you needing to hack the WordPress core.
jetpack/modules/publicize/ui.php itself states in its comments:
/**
* Only user facing pieces of Publicize are found here.
*/
You added your hashtag in the textarea which allows admins to enter a custom message (click edit and it will slide down with your hashtag).
As #Yazmin mentioned, the best way to permanently edit the message is using a filter. The filters available are wpas_default_prefix, wpas_default_message, and wpas_default_suffix.
Personally, I had no success using these filters and I'm interested in a working solution to this issue myself.
I am working on a wordpress site and would like to clarify a basic concept that is definitely very important, and this is how to customize/extend a wordpress hook (at least that's what I think I want to do!)
As the real world example, I am setting up a wp-ecommerce site. When a user adds an item to the cart, I would like to do one or two more things than the original function does. Looking through the source, I find:
/wp-content/plugins/wp-e-commerce/wpsc-includes/ajax.functions.php
with the function:
function wpsc_add_to_cart()
I know I could simply edit the code right here, but obviously that is the completely wrong way to go about it as when the plugin is updated, I will lose changes. What is the correct way to extend a function that is part of a plugin, or wordpress for that matter?
Endless thanks in advance.
You can use the wordpress action hooks to resolve the code loss while plugin upgrade.
You can remove the function which is in plugin file by using remove_action hook and do your own code by adding add_action in your function.php file. So that you can customize your plugin code from theme's function.php.
Here are the examples to explain.I hope it will help.
http://codex.wordpress.org/Plugin_API
http://themeshaper.com/2009/05/03/filters-wordpress-child-themes/
I use a little supressed notice function (it lives in my child themes function.php page), for plugins that get irritating eg: please setup twitter account to use , this kind of warning is not useful at certain stages and sometimes just do not care for it.
function supressed_notices_active(){
echo '<div class="error"><p>Supressed Notices are active</p></div>';
}
if(function_exists('the_plugin_custom_function_call')){
remove_action('the_plugin_custom_function_call' );
add_action('admin_notices','supressed_notices_active');
}else{
function test_message_from_me(){
echo '<h1>show</h1>';
}
add_action('admin_notices','test_message_from_me');
}
So I create the supressed notice function to at least create a warning, so i remember.
Check if the target function exists with the function_exists($target_function) hook
then remove this action from running with the remove_action($tag,$target_function) hook
then just add your custom function with the add_action($tag,$target_function) hook (do not need to have a separate function this could just be a closure)
then else if the function does not exist either still run a new action or leave this section, it can be useful for testing to just add anything so you atleast get some feed back.
What you could try... Copy the function within the plugin file,
paste it into your themes functions.php file,
ie:
function wpsc_add_to_cart() {
global $wpdb, $wpsc_cart;
// default values etc..etc..
// new code here?
}
the only thing with this is, if the plugin is updated and that funciton is renamed or removed, changed or something you could start to run into trouble...
could you not ask the plugin developer to possibly add your requirements to it,
possibly for a small fee? but if your using it as your main shopping cart, then chances are, that small investment could be a good thing.
Marty