So I used composer manager and drush to install POS Label and POS Label Barcode. This installed the proper PHP Barcode library dependency as well of course. I also installed the Jquery Print library AND its associated module.
I have tried disabling and re-enabling both modules as well, but no matter what, I am getting an AJAX 500 error. When I go to "print labels" and I type in the item SKU, then select the item I want, I get the AJAX error "unavailable".
Watchdog has the following log message related to this:
REFERRER https://tcldevpos.dd:8443/admin/commerce/pos/labels
MESSAGE Recoverable fatal error: Object of class stdClass could not be converted to string in commerce_pos_label_attributes_string() (line 222 of ...\sites\all\modules\commerce_pos\modules\label\commerce_pos_label.module).
Do you think this is a bug or something to do with my configuration?
I am running Drupal 7.52 with PHP 5.5, 256mb memory limit and jquery update to 1.7.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | label_printing_error-2840166-15.patch | 3.79 KB | smccabe |
Comments
Comment #2
travis-bradbury commentedCould you share what types of fields you have on
commerce_productthat are set as attributes?Comment #3
TynanFox commentedI have two fields set as attributes, one is field_attribute and the other is field_size. They are both Term References with the Select List widget. My products have other fields as well (mostly metadata like UPC, Brand name, etc.) but none of the other ones function as attributes on add to cart forms.
Comment #4
travis-bradbury commentedLooks like commerce_pos_label is assuming that the value of the field is either an array or a scalar value, but in this case it's getting an object (a taxonomy term).
Commerce Cart allows any field defined by a module that implements
hook_options_list()to be an attribute. It looks like we might need to use that function to get a list of human-readable values, then use only the value that applies to the particular product - unless there is a more direct way to render a human-friendly value from any field that would be accepted bycommerce_cart_field_attribute_eligible().Comment #5
TynanFox commentedInteresting to read about. :)
Unfortunately I am not a developer. I wish I could help solve this issue and/or create a patch - but unfortunately the solution you listed sounds mostly like a foreign language to me.
So I suppose - take it for what it is and prioritize it as you see fit. Really do wish I could be of more help - I love the philosophy of open source software. But I don't have the skills. :(
Comment #6
subhojit777Fix for this issue https://github.com/AcroMedia/commerce_pos/pull/12
Comment #7
subhojit777Comment #8
subhojit777As per discussion with @tbradbury:
Pull request is updated https://github.com/AcroMedia/commerce_pos/pull/12
Comment #9
travis-bradbury commentedThis patch is what I was thinking of in #4. Let me know what you think.
It seems a bit klunky because it involves getting a whole list of values and only selecting one, but we
don'tshouldn't have to do any special logic for taxonomy fields or any other types that might come up.I tested it successfully on a Kickstart install with single and multi-value taxonomy term fields.
I'm not sure if we can collaborate on a single pull request so I made another one:
https://github.com/AcroMedia/commerce_pos/pull/13
Comment #10
subhojit777We just need the available options. Do we still need to get the
_options_properties(). Although we are hardcoding the widget type here, but I have tested this using radio buttons, and it worked alright. Which means, the widget type and its properties are not important here, and we can skip them.I thought, the idea was to make it compatible with
commerce_cart_field_attribute_eligible(). But we are adding support for multivalued fields as well. Also, if we are adding multivalued field support, can you please put a comment here, the comment should tell the purpose of usingarray_map().Other that that, the code looks alright to me.
Comment #11
travis-bradbury commentedI think so.
$propertiesis a required parameter in_options_get_options(). It looks like it's a pretty low-overhead function that just sets some settings for escaping the values of the fields that will be displayed.Good catch. Only a single-value field should be eligible. However, when I tested it, it's really easy to set an attribute field to be multilple-value. It looks like commerce_cart deals with that by calling
commerce_cart_field_attribute_eligible()andcommerce_cart_field_instance_is_attribute(). I think it's OK for us to support multi-value fields, but the alternative is probably to add a call tocommerce_cart_field_attribute_eligible()incommerce_pos_label_attribute_fields()so that we never get a multi-value field incommerce_pos_label_attributes_string().I've updated the pull request with some comments. I also moved some function calls inside the condition on the field value so that we don't bother calling them if the field has a null value.
https://github.com/AcroMedia/commerce_pos/pull/13
Comment #12
subhojit777Code looks great! Tested locally, worked without any errors.
Comment #13
subhojit777There are two commits here https://github.com/AcroMedia/commerce_pos/pull/13, make sure that there is only one commit when you push the code.
Comment #14
TynanFox commentedSo I ignored most of everything you guys were talking about because I didn't understand it....
But I applied the patch to my dev site and now the label printing works! I don't know how sophisticated I would call this "test" but it seems like it did the job anyway...
:)
Comment #15
smccabe commentedTurned the PR back into a patch since it passed testing, mostly just for easy of use on this issue should someone want to apply the patch.
Comment #17
smccabe commented