Marie Lamoureux
01/03/2023, 8:04 AMinclude the following parameters when posting to /orders/populate
I've installed the gem, ran the migration, I can now make a product susbcribable from my admin panel by ticking a box. But nothing happens on the shop side. So I'm obviously missing a step. I don't know where/how to add the following params:
{
// other add to cart params
subscription_line_item: {
quantity: 2, // number of units in each subscription order
subscribable_id: 1234, // which variant the subscription is for
interval_length: 1, // time between subscription activations
interval_units: "month", // plural qualifier for length (day/week/month/year)
end_date: '2011/12/13' // stop processing after this date (use null to process ad nauseam)
}
}
Could anyone help me please ?Naoki Mi
01/03/2023, 8:06 AMMarie Lamoureux
01/03/2023, 8:22 AMkennyadsl
kennyadsl
kennyadsl
kennyadsl
Marie Lamoureux
01/03/2023, 8:36 AMkennyadsl
Marie Lamoureux
01/04/2023, 2:11 PMbutton_tag to my fields_for :'subscription_line_item'
Any idea what I'm missing here ?kennyadsl
kennyadsl
Marie Lamoureux
01/04/2023, 2:27 PMproduct_submit.html.erb which is rendered in cart_line_items/_form.html.erbkennyadsl
Marie Lamoureux
01/04/2023, 2:44 PMkennyadsl
kennyadsl
cart_line_items_controller of your application, it should work:
after_action(
:handle_subscription_line_items,
only: :create,
if: ->{ params[:subscription_line_item] }
)
# and in the private section:
def handle_subscription_line_items
# you can put a binding.pry here to debug and see if this callback gets called
line_item = @current_order.line_items.find_by(variant_id: params[:variant_id])
create_subscription_line_item(line_item)
endMarie Lamoureux
01/04/2023, 5:50 PMcreate_subscription_line_item'
Could this be because, somehow, the cart_line_items doesn't have .prepend(SolidusSubscriptions::Spree::OrdersController::CreateSubscriptionLineItems) like in the decorator you shared ? I've tried adding the same line of code but it didn't helpkennyadsl
Marie Lamoureux
01/04/2023, 7:59 PMkennyadsl
include SolidusSubscriptions::SubscriptionLineItemBuilder
in the cart_line_items_controller.kennyadsl
Marie Lamoureux
01/05/2023, 12:51 PMValidation failed: Subscribable must exist, Subscribable can't be blank ?kennyadsl
kennyadsl
Marie Lamoureux
01/06/2023, 11:46 AMkennyadsl
kennyadsl
Marie Lamoureux
01/08/2023, 3:03 PMkennyadsl
kennyadsl
Marie Lamoureux
01/09/2023, 2:21 PM