Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8445181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:35:46+00:00 2026-06-10T09:35:46+00:00

I am working on a small app that allows for users to add a

  • 0

I am working on a small app that allows for users to add a product (or subscription) to their cart. Upon creating their account, the new user is sent to a “bundle” page where it asks if they would like to add a different subscription to a different product altogether for a bundled price.

Here is where I am stuck: Upon submitting the user’s credit card info I get slightly “lost in translation” when trying to setup the bundle pricing to submit to Authorize.net (I understand how to authnet, not the question here).

Here is what I have so far:

current_order.products.includes(:client).each do |product|
          transaction = current_order.submit_order_to_authnet(product)

            if transaction.result_code == 'Ok'
          new_group = Group.create!(:name => "#{current_user.full_name} #{product.title}", :type => 'school', :start_date => Time.now, :status => 'active', :site_id => 1)
          primary = session[:primary_product_id].eql?(product.id) ? true : false

          # Add subscription to Group
          new_group.add_subscription(product, current_order, transaction.subscription_id, 'active', primary)
          # Add Subscription to CurrentOrder
          current_order.subscriptions << new_group.subscriptions.last
          # Add user to NewGroup
          current_user.groups << new_group
          # Create New Group Admin
          new_group.group_admins.create(:user_id => current_user.id)
          # Send success email
          OrderMailer.checkout_confirmation(current_user).deliver
        else
          errors << transaction.result_code
        end
      end

I am trying to figure out the best solution when it comes to looping through each product in the users current_order because the second subscription in the users cart is the subscription that gets the discount applied too. I know I can write something like this:

current_order.products.includes(:client).each do |product|
    if current_order.products.many? and product == current_order.products.last
        # run discount logic
    else
        # continue with authnet for single subscription
    end
end

But I am just not sure if that is a best practice or not. Thoughts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T09:35:47+00:00Added an answer on June 10, 2026 at 9:35 am

    So the only subscription that doesn’t get discounted is the first one? Why not write it like this:

    current_order.products.includes(:client).each do |product|
      if product == current_order.products.first
        # continue with authnet for single subscription
      else
        # run discount logic
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’m currently working on a small web app that allows people to search for
I'm working on a small app that uses the Facebook API. What I want
I am working on an existing ASP.NET MVC app that started small and has
Relatively new to WinForms but I'm working on a small business app. Anyway, where
I used to have a small chat app(which was almost working), that uses PHP,
I'm working on a small app that will allow the user to login to
I'm working on a small app that makes use of the jQuery plugin Fullcalendar.
I have a small IPhone app that I am working on and I am
I am working on an Android mapping app that allows a user to type
For a new SaaS app that I'm working on, I want the end user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.