- Support forum for the Product Price by Formula for WooCommerce.
- This topic has 8 replies, 2 voices, and was last updated 5 years, 7 months ago by Tom Anbinder.
-
AuthorPosts
-
April 3, 2019 at 3:38 pm #99096ZackGuest
Hi Tom, I am really interested in buying your plugin. However, am I able to use your plugin with variable product attributes and using the attribute values into the formula? For example, I have a custom product attribute called “Number Of Prints” that is used for variations; Can I use it as part of the formula?
April 3, 2019 at 5:09 pm #99097Hi Zack,
Please try:
[product_meta key="attribute_pa_number-of-prints"]
April 3, 2019 at 5:19 pm #99098ZackGuestThank you so much for your reply Tom! Can I ask another question? What if my attribute is of a text value instead of an integer value? Can I still use the conditional if_value shortcode?
April 3, 2019 at 5:56 pm #99099ZackGuestFor example:
[if_value value=”{product_meta key=’attribute_pa_media-type’}” compare_operator=”equal” compare_to_value=”paper”]x*4.9[/if_value]April 3, 2019 at 6:39 pm #99100Wasn’t possible (as
[product_meta]
shortcode automatically converted the value to number), however, I have just added newconvert_to_numeric
shortcode attribute to[product_meta]
in our development version, so now you should use:[if_value value="{product_meta key='attribute_pa_media-type' convert_to_numeric='no'}" compare_operator="equal" compare_to_value="paper"]x*4.9[/if_value]
April 3, 2019 at 6:52 pm #99101ZackGuestWow! This is amazing. Great work man. However, can I confirm if this plugin will work with variable product?
For example, my variable product have 2 options (attributes).
1: Media Type (Paper, Cardboard)
2: Number Of Prints (1, 2, 3)Formula:
[if_value value=”{product_meta key=’attribute_pa_media-type’ convert_to_numeric=’no’}” compare_operator=”equal” compare_to_value=”paper”]
(x+0.2)*{product_meta key=’attribute_pa_media-type’}
[/if_value]
[if_value value=”{product_meta key=’attribute_pa_media-type’ convert_to_numeric=’no’}” compare_operator=”equal” compare_to_value=”cardboard”]
(x+0.5)*{product_meta key=’attribute_pa_media-type’}
[/if_value]So when I select my options in the frontend, the pricing will update as accordingly?
April 3, 2019 at 7:06 pm #99102Yes, it will work with variable products (i.e. will set different prices for each variation depending on variation’s attributes). Small fix in formula is needed though:
[if_value value="{product_meta key='attribute_pa_media-type' convert_to_numeric='no'}" compare_operator="equal" compare_to_value="paper"] (x+0.2)*[product_meta key="attribute_pa_number-of-prints"] [/if_value] [if_value value="{product_meta key='attribute_pa_media-type' convert_to_numeric='no'}" compare_operator="equal" compare_to_value="cardboard"] (x+0.5)*[product_meta key="attribute_pa_number-of-prints"] [/if_value]
I.e.
{
and}
brackets are only used inside shortcodes attributes, and inside shortcode’s content you need to use normal (i.e. square) brackets ([
and]
) for shortcodes.April 3, 2019 at 7:21 pm #99103ZackGuestAWESOME! Is there anyway I can try a demo of the frontend first? I can’t seem to find any demo websites here.
April 8, 2019 at 3:57 pm #99104If anyone else has similar tasks – we’ve just released new plugin v2.2.1, where we have:
1. added
[product_attr]
shortcode, which would be the correct way of retrieving the product’s attributes, e.g.:[product_attr attribute="number-of-prints"]
You can also get product attribute’s value as suggested earlier by:
[product_meta key="attribute_pa_number-of-prints"]
However it seems that this way only works for variations, but not for simple type product’s attributes, while
[product_attr]
shortcode works for all types of products.2. added
convert_to_numeric
attribute to the[product_meta]
shortcode (attribute defaults toyes
). -
AuthorPosts
- The forum ‘Product Price by Formula for WooCommerce’ is closed to new topics and replies.