hello together,

im trying to add a views-bulk-operation to the commerce product list, which alters the [product:commerce-price:data] field to include or exclude VAT on demand.

so far i created a component in rules which sets the field price:data to a new value and shows it within the view.

in my configuration the field config with tax is:
a:2:{s:10:"components";a:0:{}s:11:"include_tax";s:4:"mswt";}
and without tax:
a:1:{s:10:"components";a:0:{}}

now the problem is to get the values into the field without having the need to know the ids of taxes and components.

any insights would be helpful

greetings fooby

ps: sorry for my bad english :)

CommentFileSizeAuthor
#2 vat_component.png70.46 KBfooby

Comments

rfay’s picture

Component: Views integration » Price

I *think* this is about price, so changing component.

For what you want to do, we just need the Commerce API that's needed to do it. I think the way to sort this out is to see what Commerce does when you click that checkbox.

fooby’s picture

StatusFileSize
new70.46 KB

i added a screenshot of my rules component.

the problem is that i cant choose one of the parameters and some exceptions are thrown

Warning: implode(): Invalid arguments passed in RulesDataUIListText::inputForm() (line 347 of /var/www/virtual/triebwerk.ph/dc/htdocs/profiles/commerce_kickstart/modules/rules/ui/ui.data.inc).
    Notice: Undefined index: #delimiter in rules_ui_list_textarea_pre_render() (line 781 of /var/www/virtual/triebwerk.ph/dc/htdocs/profiles/commerce_kickstart/modules/rules/ui/ui.forms.inc).

isnt list of text the data type i need?

rszrama’s picture

There won't be any way to do this purely through Rules, because you cannot manipulate the contents of the data array just by using basic Rules functions (unless you're using a PHP action). This will require some sort of custom action where you can in fact choose from a list of available VATs, because the Tax module needs to know the name of the tax to include when it loads a product price. No way around that.

rfay’s picture

Status: Active » Fixed

Calling it fixed then...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

czperry’s picture

did you ever solve this one fooby? if you solved with php can you share the code snippet. thanks

czperry’s picture

Issue summary: View changes

removed code tags

darrenwh’s picture

I've found this to work:

$product = commerce_product_load(4616);
$product ->commerce_price[LANGUAGE_NONE][0]['data']['include_tax'] = 'vat';
entity_save('commerce_product', $product );