Skip to Content Skip to Menu

Programmatically generate purchase item

  • sstoks
  • sstoks
  • ONLINE
  • Posts: 5
  • Thanks: 0
  • Karma: 0
1 day 3 hours ago #343096 by sstoks
Replied by sstoks on topic Programmatically generate purchase item
Hi,

I'm not familiar with "CBSubs Options", and I am just looking in the "Plans" pages. I am comparing my "Workshop" plan with the other plans which apparently worked in the past, and I am quite sure that I have everything set up the same way.

Interestingly, if I am logged in to the site, I get this "_getReqParam() on null" error; if I do not log in (I.e., try to order as "guest"), then I get one line further in the script and now end up with "Chosen plans combination is not allowed (you must choose coherent plans selection, e.g. mandatory subscription(s) must be active or mandatory plan(s) must be chosen)." (slightly different from the first error, about the parent subscription).

I agree with your warning that I'm trying to use CBSubs for something it wasn't designed for. Perhaps I should focus my attention on the "webshop" part of the site (HikaShop) and see if I can use that one. There is a relatively simple API available there which lets me create line items for orders.

The drawback here is that I have to configure payment processors for both CBSubs and for this webshop. I can imagine that if people run a "community-site" (with paid subscriptions), then having a simple way to sell the occasional T-shirt or printed mug as support items would be a welcome addition - especially because the invoice and payment processing of CB is so slick.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 50075
  • Thanks: 8568
  • Karma: 1468
1 day 3 hours ago - 1 day 3 hours ago #343097 by krileon
Replied by krileon on topic Programmatically generate purchase item
Normally to sell a T-Shirt in addition to a subscription or independently you'd just use a Merchandise plan. Generating baskets of unknown items with unknown prices is basically invoicing software.

So if whatever you're trying to add to a basket is a static item you can just create plans for them and then it's as simple as redirecting them to a URL that'll build the basket for you. The URL to do this is at the top of each plan (add to basket) and you can have multiple plan ids in that URL to add multiple plans. This basically lets you have whatever UI you want for building baskets, but again requires plans.

So lets say for example I've Plan A with an ID of 1 and Plan B with an ID of 2. My below URL would select both, add them to the basket, then display the basket to me if I'm logged in. If I'm not logged in it'll display registration with both plans selected already.

index.php?option=com_comprofiler&view=pluginclass&plugin=cbpaidsubscriptions&do=addplanstobasket&plans=1-2

CBSubs Options is an integration you'd need to install. It lets you add custom fields to plans basically. Those fields then can modify the price of a plan in many ways. So for example lets say you've a T-Shirt plan and that T-Shirt comes in Red, Blue, Green, and White colors. You could add a dropdown to the plan that lets them select the color. The color can then adjust the price (or not! it doesn't have to!) of the plan. We've a demo of this on our demo site below.

demo.cbdemosites.com/demos/community-builder/registration

The dropdown for Additional Seats in Professional is a CBSubs Option field. The extra pricing options in Developer are also CBSubs Options. Below is my blog posts about CBSubs Options for more examples of what it's capable of.

www.joomlapolis.com/blog/kyle/18983-cbsubs-options
www.joomlapolis.com/blog/kyle/18998-dynamic-plan-pricing
www.joomlapolis.com/blog/kyle/19070-cbsubs-options-new-fields

It's just unclear exactly the usecase you currently have so It's difficult for me to understand your needs exactly. Stuff like variable pricing is done using promotion codes, tax rules, donation plans, and CBSubs Options. All of those let you modify a baskets pricing. Without more information or if possible PM URLs with instructions for a normal user experience I don't really know what more to suggest. I'm still exploring some options API wise to generate baskets with unknown line items, which maybe possible but I can't promise anything there.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 1 day 3 hours ago by krileon.

Please Log in or Create an account to join the conversation.

  • sstoks
  • sstoks
  • ONLINE
  • Posts: 5
  • Thanks: 0
  • Karma: 0
1 day 3 hours ago - 1 day 2 hours ago #343101 by sstoks
Replied by sstoks on topic Programmatically generate purchase item
Thanks for the explanation about "CBSubs Options". I checked the links you posted. Do I understand correctly that such an "integration" is both a "programmatic" extension (that adds these fields to the various data types) _and_ the accompanying UI part so you can edit those fields without using PHP?

Also, when taking a look at the "Plugin management" page of CB in my Joomla backend, I can't say I've become "less confused" :-) For sure there isn't a "CBSubs Options", but I notice there is both a "CB Paid Subscriptions" plugin (which is at version 4.8.0) and a "CBSubs Paid Subscriptions" which is at version 3.0.0 and which displays a warning saying it's not compatible with my current CB version (which I think is 2.11.0).

If I search for "CBSubs Options" in the "Install CB Plugin" page, then it finds it, shows me a nice description of what it is, along with a "subscribe" button which takes me to the Joomlapolis website about CB Paid Subscriptions - but I _have_ that. I'm afraid I don't "get" it. How does one install such "integrations"?

Sorry about the newbe questions. This is all far less intuitive than I hoped :-)

EDIT: By the way: this "index.php?option=com_comprofiler&view=pluginclass&plugin=cbpaidsubscriptions&do=addplanstobasket&plans=1-2" was a very helpful tip.  I can see that when I enter the ID of my new plan, it gives me a nice error page with "Amount not allowed"; if I fill in the ID of an older plan (which is still "published") then I get exactly what I want to see: a summary of the order, with my billing address already filled in, and links to the payment processors at the bottom.  This will help me debug much more efficiently!
Last edit: 1 day 2 hours ago by sstoks.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 50075
  • Thanks: 8568
  • Karma: 1468
10 hours 27 minutes ago #343115 by krileon
Replied by krileon on topic Programmatically generate purchase item

Do I understand correctly that such an "integration" is both a "programmatic" extension (that adds these fields to the various data types) _and_ the accompanying UI part so you can edit those fields without using PHP?

Yes, it adds fields to plans and dynamically alters their pricing with zero coding necessary.

Also, when taking a look at the "Plugin management" page of CB in my Joomla backend, I can't say I've become "less confused" :-) For sure there isn't a "CBSubs Options", but I notice there is both a "CB Paid Subscriptions" plugin (which is at version 4.8.0) and a "CBSubs Paid Subscriptions" which is at version 3.0.0 and which displays a warning saying it's not compatible with my current CB version (which I think is 2.11.0).

Sounds like you've a CBSubs plugin installed that's out of date or discontinued. Within CB > Plugin Management > Install From Web you can easily update your CB install.

If I search for "CBSubs Options" in the "Install CB Plugin" page, then it finds it, shows me a nice description of what it is, along with a "subscribe" button which takes me to the Joomlapolis website about CB Paid Subscriptions - but I _have_ that. I'm afraid I don't "get" it. How does one install such "integrations"?

You don't have a site key configured. You should see a notice at the top of install from web about that. You can configure it in CB > Configuration > Integrations.

Sorry about the newbe questions. This is all far less intuitive than I hoped

There's nothing to apologize for. I'm glad to help! 😊

I can see that when I enter the ID of my new plan, it gives me a nice error page with "Amount not allowed"

That's probably because you're linking to a donation plan. Those expect a donation amount so linking to them is a bit awkward as the entire input path has to be supplied for the form field. I can provide that if you need it, but I'd recommend moving to CBSubs Options from the sounds of your usecase.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • sstoks
  • sstoks
  • ONLINE
  • Posts: 5
  • Thanks: 0
  • Karma: 0
4 hours 26 minutes ago #343121 by sstoks
Replied by sstoks on topic Programmatically generate purchase item
Hi Kyle,

OK, progress. There was a "site key" filled in, but I suppose this one was from my predecessor's account.  I generated a new one on this site, put it in there, and was then able to update everything to their latest versions.  I also added CBSubs Options, and it looks like this indeed has the functionality I need.  A bit more context of what I'm trying to accomplish:  Our society organizes a scientific workshop/conference every year.  People can register on the site, and there are various types of tickets, each with their own price (members, non-members, retired members, students, one-day pass, etc.)  Also, they can opt for certain "extras" (extra dinner ticket, hardcopy of the conference abstracts, things like that).  In the current set-up, it turns out that the previous maintainer(s) had to generate new plans for each of these options (so a small dozen for each new workshop), and the registration form used this script to search-and-replace the plan descriptions into the form, and re-routed the form data upon submission to the CBSubs basket page.
My plan is to use one generic "ticket" plan and perhaps one extra generic "extra item" plan, and use the CBSubs Options functionality to fill in the correct data (description, price) into these plans, and add them to the basket.  This way, the form is the driving source of data - and other board members of this society can more easily add/change options for next year's workshop.  It's much easier to explain to them "add ticket options to the first dropdown menu and add optional items to the checkbox area below" then it is to explain to them how to copy last year's paid plans and make the necessary changes.

OK, so far so good.  I have copied a "working" (merchandise) plan twice.  On the top of the main edit page of a plan, it displays "URL of plan to display only this plan" and "URL to add plan to basket".  The first one works almost completely as expected: I'm taken to a "Subscriptions" page where it looks like I can "upgrade" to this plan (with the contents displayed nicely, including the "Workshop Ticket" and "generic placeholder text" and price which I set as defaults.  It includes a nice "BUY" button underneath.  But, if I try the second "add plan to basket" URL, it shows me an invoice-type "Summary" and my (correct) Billing address info, but the summary displays the original title and price of the plan I copied (and changed!)  Any idea where that comes from?  Is there some cache I need to clear?

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum