forked from solidusio/solidus_subscriptions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update gem to support the latest Solidus version(4.4)
- Loading branch information
1 parent
fe9b6d5
commit 86cf5eb
Showing
11 changed files
with
100 additions
and
61 deletions.
There are no files selected for viewing
16 changes: 10 additions & 6 deletions
16
app/overrides/views/admin_subscribable_product_checkbox.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
Deface::Override.new( | ||
virtual_path: "spree/admin/products/_form", | ||
name: "solidus_subscriptions_product_subscribable_checkbox", | ||
insert_after: "[data-hook='admin_product_form_promotionable']", | ||
partial: "spree/admin/products/subscribable_checkbox" | ||
) | ||
module Views | ||
module AdminSubscribableProductCheckbox | ||
Deface::Override.new( | ||
virtual_path: "spree/admin/products/_form", | ||
name: "solidus_subscriptions_product_subscribable_checkbox", | ||
insert_after: "[data-hook='admin_product_form_promotionable']", | ||
partial: "spree/admin/products/subscribable_checkbox" | ||
) | ||
end | ||
end |
16 changes: 10 additions & 6 deletions
16
app/overrides/views/admin_subscribable_variant_checkbox.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
Deface::Override.new( | ||
virtual_path: "spree/admin/variants/_form", | ||
name: "solidus_subscriptions_variant_subscribable_checkbox", | ||
insert_after: "[data-hook='track_inventory']", | ||
partial: "spree/admin/variants/subscribable_checkbox" | ||
) | ||
module Views | ||
module AdminSubscribableVariantCheckbox | ||
Deface::Override.new( | ||
virtual_path: "spree/admin/variants/_form", | ||
name: "solidus_subscriptions_variant_subscribable_checkbox", | ||
insert_after: "[data-hook='track_inventory']", | ||
partial: "spree/admin/variants/subscribable_checkbox" | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
if !Spree::Backend::Config.respond_to?(:menu_items) | ||
Deface::Override.new( | ||
virtual_path: 'spree/admin/shared/_menu', | ||
name: :add_subcriptions_admin_link, | ||
insert_bottom: "[data-hook='admin_tabs']", | ||
partial: 'spree/admin/shared/subscription_tab' | ||
) | ||
module Views | ||
module AdminSubscriptionsMenuLink | ||
if !Spree::Backend::Config.respond_to?(:menu_items) | ||
Deface::Override.new( | ||
virtual_path: 'spree/admin/shared/_menu', | ||
name: :add_subcriptions_admin_link, | ||
insert_bottom: "[data-hook='admin_tabs']", | ||
partial: 'spree/admin/shared/subscription_tab' | ||
) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
Deface::Override.new( | ||
virtual_path: 'spree/admin/users/_tabs', | ||
name: 'solidus_subscriptions_admin_users_subscriptions_tab', | ||
insert_bottom: "[data-hook='admin_user_tab_options']", | ||
partial: 'spree/admin/users/subscription_tab' | ||
) | ||
module Views | ||
module AdminUsersSubscriptionsTab | ||
Deface::Override.new( | ||
virtual_path: 'spree/admin/users/_tabs', | ||
name: 'solidus_subscriptions_admin_users_subscriptions_tab', | ||
insert_bottom: "[data-hook='admin_user_tab_options']", | ||
partial: 'spree/admin/users/subscription_tab' | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
Deface::Override.new( | ||
virtual_path: "spree/products/_cart_form", | ||
name: "subscription_line_item_fields", | ||
insert_after: "[data-hook='inside_product_cart_form']", | ||
partial: "spree/frontend/products/subscription_line_item_fields" | ||
) | ||
module Views | ||
module SubscriptionLineItemFields | ||
Deface::Override.new( | ||
virtual_path: "spree/products/_cart_form", | ||
name: "subscription_line_item_fields", | ||
insert_after: "[data-hook='inside_product_cart_form']", | ||
partial: "spree/frontend/products/subscription_line_item_fields" | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 29 additions & 20 deletions
49
...s_subscriptions/install/templates/app/views/cart_line_items/_subscription_fields.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,39 @@ | ||
<%= content_tag :h3, t('.subscription_fields') %> | ||
<%= fields_for :'subscription_line_item', SolidusSubscriptions::LineItem.new do |ff| %> | ||
<div> | ||
<%= ff.label :quantity, t('.quantity') %> | ||
<%= ff.number_field :quantity %> | ||
<%= ff.label :quantity, t('.quantity_suffix') %> | ||
</div> | ||
|
||
<div> | ||
<%= ff.label :interval_length, t('.interval_length') %> | ||
<%= ff.number_field :interval_length %> | ||
|
||
<%= ff.collection_radio_buttons :interval_units, SolidusSubscriptions::LineItem.interval_units.to_a, :first, :first %> | ||
</div> | ||
|
||
<%= ff.hidden_field :subscribable_id %> | ||
<% if @product.subscribable %> | ||
<%= content_tag :h3, t('.subscription_fields') %> | ||
<%= fields_for :'subscription_line_item', SolidusSubscriptions::LineItem.new do |ff| %> | ||
<div> | ||
<%= ff.label :quantity, t('.quantity') %> | ||
<%= ff.number_field :quantity %> | ||
<%= ff.label :quantity, t('.quantity_suffix') %> | ||
</div> | ||
|
||
<div> | ||
<%= ff.label :interval_length, t('.interval_length') %> | ||
<%= ff.number_field :interval_length %> | ||
|
||
<%= ff.collection_radio_buttons :interval_units, SolidusSubscriptions::LineItem.interval_units.to_a, :first, :first %> | ||
</div> | ||
|
||
<%= ff.hidden_field :subscribable_id %> | ||
<% end %> | ||
<% end %> | ||
|
||
<script> | ||
document.addEventListener("DOMContentLoaded", function(e) { | ||
var cartForm = document.querySelector('.product-page__info form'); | ||
var cartForm = document.querySelector('form[action="/cart_line_items"]'); | ||
|
||
cartForm.addEventListener('submit', function(e) { | ||
var quantityInput = e.target.querySelector('[name*="quantity"]'); | ||
var subscriptionQuantityInput = e.target.querySelector('[name*="subscribable_id"]'); | ||
var variantInput = e.target.querySelector('[name*="variant_id"]:checked'); | ||
var subscribableInput = e.target.querySelector('[name*="subscription_line_item[subscribable_id]"]'); | ||
|
||
if (!variantInput) { | ||
variantInput = cartForm.querySelector('[name="variant_id"]'); | ||
} | ||
|
||
subscribableInput.value = variantInput.value; | ||
|
||
subscriptionQuantityInput.value = quantityInput.value; | ||
return true; | ||
}); | ||
}); | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters