-
Notifications
You must be signed in to change notification settings - Fork 2
/
customer_returns_extension.rb
31 lines (26 loc) · 1.13 KB
/
customer_returns_extension.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Uncomment this if you reference any of your controllers in activate
# require_dependency 'application'
class CustomerReturnsExtension < Spree::Extension
version "1.0"
description "Allows the customer to initiate their own Returns/RMA from their order detail page"
url "http://yourwebsite.com/customer_returns"
def activate
# there must be some reason!! (and at least one variant to be returned!!!)
ReturnAuthorization.class_eval do
validates_presence_of :reason, :on => :create
#validates_presence_of :variant # <--- this cant be done on create because the controller is weird.
end
# make your helper avaliable in all views
OrdersHelper.module_eval do
def link_to_tracking tnum, method, options={}
if method.name.match /\bUPS\b/
link_to tnum, 'http://wwwapps.ups.com/WebTracking/processInputRequest?TypeOfInquiryNumber=T&InquiryNumber1='+tnum, options
elsif method.name.match /\bUSPS\b/
link_to tnum, 'http://trkcnfrm1.smi.usps.com/PTSInternetWeb/InterLabelInquiry.do?origTrackNum='+tnum, options
else
tnum
end
end
end
end
end