Term reference field support.

This module can not display the term reference field yet.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nchar’s picture

Thats a great suggestion! I am going to add support for term reference fields soon. Thanks for your feedback!

nchar’s picture

Status: Active » Needs work
rudy.barrett’s picture

Hey I'm wondering if any progress has been made on this feature. I would very much like to see it in place as well.
Thanks again for this awesome module, with taxonomy terms being used with it I will be able to completely ditch UC.

joep.hendrix’s picture

Great module!
The term reference option would be great.

Cheers!

Maroli’s picture

When would you have this ready? I am urgently needing this.

What I am doing is that I need to adjust price (and SKU) based on the size. This module seems to be able to achieve the price part. If adding another field (SKU) is also possible, please inform me about that.

If you have built in the support for term reference, pls let me know.

mglaman’s picture

Here is my patch to add term reference field support. Created function "commerce_pricing_attributes_get_allowed_values" which checks what module the field belongs to. If it is a term reference field it will cycle through the terms and create an array similar to one outputted by the list field. This way there was no need for major overhaul of code.

Also in rules added an is_object check so that the rules knew how to handle the attribute value.

            if(is_object($selected_option))
                $selected_option = $selected_option->tid;

I did basic testing, have a client that will be using some in-depth products using pricing attributes based on term references. If I run into anything in the next few days I'll update my patch.

wqmeng’s picture

@mglaman

Thanks a lot for the patch, I have tried it and found that it not work very well with the module "Inline Entity Form", I always get this error and can not submit any change when edit the product with the Inline Entity Form.

    Option set "xxxxxxxxxxxxxxxxxxxxx" must have at least one field eneabled.
    You have selected as default value of the option set "xxxxxxxxxxxxxxxxxxxxx" a disabled option. Please enable the option or change the default option.
    You have selected as default value of the option set "xxxxxxxxxxxxxxxxxxxxx" a disabled option. Please enable the option or change the default option.
    Option set "xxxxxxxxxxxxxxxxxxxxx" must have at least one field eneabled.
mglaman’s picture

@wqmeng

Thanks for checking it out. I didn't have issues with the inline entity form - just using demo Commerce Kickstart store for testing, and client's project site. When I view products and "Quick Edit" I'm able to edit the price and status without any errors. Ditto when editing the product variation from within a container (how I was testing when debugging patch.)

Can you point me in right direction to re-create this?

dgastudio’s picture

i have both type of fields in optionset, default selects and taxonomy. It works fine, except one error

Error message
Notice: Undefined index: commerce_pricing_attributes in commerce_pricing_attributes_field_widget_form() (line 422 of /home/u7394/domains/shuba.u7394.shiva.vps-private.net/sites/all/modules/commerce_pricing_attributes/commerce_pricing_attributes.module).

any advice?

dgastudio’s picture

solved.

if (isset($option_field_instance['settings']['commerce_pricing_attributes'])){
$defaults = $option_field_instance['settings']['commerce_pricing_attributes'];
}

wqmeng’s picture

Hello mglaman,

That I have the same problem with this one?
#2043727: Multiple Pricing Attribute fields on one product throws error (workaround)

Do you have tested your products with Multiple Pricing Attributes which are both Term reference? I have create a new product with Multiple Pricing Attributes, still get the same errors.

Thanks

mglaman’s picture

Hey @wqmeng

I actually haven't used a product that has two product pricing attributes fields - just one with a LOT of options -- example: https://beta.justcamo.com/browse/auto/custom-seat-covers (launching site on the 11th, so if that is down/hidden, just remove beta)

I haven't had much time to debug my patch and flush it out, as I know there is a lot more work to be done to it, such as @kervi's comments.

amaria’s picture

Thanks for this patch! To make this work for a multi-select term field, I added the following code to your added if statement in the rule...

            // If taxonomy in array, need the tid of each object in the array
            else if (is_array($selected_option) && is_object($selected_option[0])) {
              foreach ($selected_option as $aryKey => $term) {
                $temp[$aryKey] = $term->tid;
              }
              $selected_option = $temp;
            }

Will make a patch later...

soliyappan’s picture

Issue summary: View changes
Status: Needs work » Fixed

Thanks mglaman ! #6 working fine .

mglaman’s picture

Status: Fixed » Needs work

soliyappan, marking as fixed means it has been committed. Please review the Issue queue handbook

The patch needs work to have kervi's comments added in, and should have amaria's notes added in as well. When patch gets re-rolled it can be marked "Needs Review" so people can test and RTBC so maintainers know to commit.

soliyappan’s picture

Category: Feature request » Bug report

Ah ok mglaman, I am new to Drupal Community, Now i am facing this error in my site

Notice: Undefined variable: options in commerce_pricing_attributes_get_allowed_values() (line 1376 of /home2/v113/public_html/sites/all/modules/commerce_pricing_attributes/commerce_pricing_attributes.module).

Any help?

mglaman’s picture

No problem, soliyappan! The queues are a bit to get used to ;)

I'm not sure, I haven't worked on patch since I first posted it to get the client's site working, which was very specific in its use case. I tried to generalize the patch as much as I could but will need others to help contribute to patch via findings in order to improve.

Basically that's saying the $options variable is never defined.

+++ b/commerce_pricing_attributes.module
@@ -1346,10 +1346,34 @@ function commerce_pricing_attributes_menu(){
+function commerce_pricing_attributes_get_allowed_values($option_field, $option_field_instance) {
+  if($option_field['module'] == 'taxonomy') {
+      $vocabulary_name = $option_field['settings']['allowed_values'][0]['vocabulary'];

Needs to initialize $options as empty array

iampuma’s picture

Status: Needs work » Reviewed & tested by the community

Why is this not yet ported after so long. Patch works perfectly.

crevko’s picture

Hello, patch from #6 works fine. Is here some possibility display list of terms on product page as images? Taxonomy terms in my project contains image field, and it would by more attractive for user display them instead of a name.

nexg’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta4
Issue tags: +sorting

The patch works for term reference but default taxonomy term sort/weight not obeyed.