shopify-script-creator
shopify-script-creator copied to clipboard
Fix for `undefined method 'map' for nil`
Hi, thanks for this awesome project!
I found a slight issue which caused a runtime error. We used the script creator to do a 'free gift over £x' deal, and ran into a slight but that happened seemly at random. Using Shopify's debug tools did not show any rhyme or reason for what could be causing it.
This PR is just a patch to return false instead of causing the script to panic.
Hello, thanks for the PR! That is very strange, I wouldn't expect that to ever happen. The change would need to be here instead as the changed file is generated based on that. There's some information about how that works here.
However, I think since if this can happen here, it would be better to change this to guard all the qualifiers and do something like:
cart.line_items.send(@li_match_type) do |item|
next false if item.nil?
qualifier.match?(item)
end
Hi, sorry for the delay and thanks for the feedback, I've done the changes. It generated the script with the correct fix, but I have not been able to test it in production just yet. It seems to work when testing in a dev shop.
I tested this and it doesn't cause any issues with my test scripts, I've never hit the nil
line item but this should take care of that. It will have an effect on the all
items matching case since we're returning false
, but I think that's probably fine since an error would have also caused the script not to work anyway. Going to merge it in. Thanks!