Loading...

spree-user@googlegroups.com

[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: [spree-user] Accessing Line Items During Checkout Question Ryan Bigg Mon Feb 20 12:00:55 2012

Here you are calling variant on the collection of line_items, when actually 
it's a method for a *single* line_item. Perhaps you meant to iterate over them 
using something like self.line_items.each { |li| li.variant.some_more_code }? 


On Monday, 20 February 2012 at 2:30 PM, Simon M wrote:

> Hello
> 
> I've modified Spree so that we can sell digital voucher codes. These
> voucher codes are stored in another rails3 application and I've set
> spree up to connect to the other application via its api (using
> httparty).
> 
> The above works ok, so far...
> 
> However, I am having problems accessing a new product attribute
> created to define which voucher 'batch'. This is required for the
> get / post request to select and update voucher. I've added 'batch_id'
> to the products table and can see this when checking out if I override
> the order_details view with:
> 
> <%= item.variant.product.batch_id %>
> 
> However, if I use the following to try and pull it out, I get an error
> saying 'variant' is an undefined method:
> 
> def select_random_user_not_sold
> batch_id = self.line_items.variant.product.batch_id
> Spree.get("/api/v1/radcheck/spree_select_random.xml?
> batch_id=#{batch_id}")
> end
> 
> Moreover, I've subsequently realised that I need to 'get' a voucher
> for each line_item in the card (assuming they're all vouchers). Are
> the two problems related?
> 
> Thanks in advance.
> 
> Simon
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Spree" group.
> To post to this group, send email to [EMAIL PROTECTED] (mailto:[EMAIL 
> PROTECTED]).
> To unsubscribe from this group, send email to [EMAIL PROTECTED] 
> (mailto:[EMAIL PROTECTED]).
> For more options, visit this group at 
> http://groups.google.com/group/spree-user?hl=en.
> 
> 


-- 
You received this message because you are subscribed to the Google Groups 
"Spree" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/spree-user?hl=en.