Expressing side effects in jsonapi response - json-api

I'm having en existential crisis on how to represent side effects in a jsonapi response.
Scenario:
I have a cart that contains items and a discount promotion 3for2.
If the cart contains 3 items eligible for that promotion and one is then removed. How can/should this side effect be communicated in the response.
Currently we return a representation of the cart, so the response will show what the cart contains but I'm keen on how to highlight that an item has been removed/updated as a result of an update/delete of another item.

Related

How to bind a calculated field to a stripe feed as payment amount?

i'm using Stripe Add-On over Gravity Forms to perform payments. A user can even use to pay one shot the whole amount or make it split down to 4 payments.
Let's say the form total amount is 1 000 $. We give the opportunity to the user to go on 4 payments of 250 $ instead. The whole thing is in place, we used Gravity Forms little code to stop Stripe subscription after 4 payment process. (https://docs.gravityforms.com/cancel-stripe-subscription-payments/).
I was able to put down a number type field to calculate the total amount (1000) divided by 4 (250)... but the Stripe feed only accept product field or Total Field as payment amount. And if I use product field to do the calculation, it simply add the calculated amount (250 $) to the form total (1000 $), so whe're now up to 1250 $.
Any Idea to tweak a little something by code or workaround using fields only ?
This is the last step to the whole project, ... ouff !Thank you.
Just got it.
Two ways :
1- By code using gform_submission_data_pre_process_payment.
- You could change the payment amount. https://docs.gravityforms.com/gform_submission_data_pre_process_payment/.
- Than work with number field (calculation) to show the amount to the end user.
2- Using Product field as Calculation (with CSS Trick).
- Do your math thing like : {Total} / 4
- Do NOT disable Qty option (otherwise it gonna add the amount to your total since he thinks Qty = 1).
- On the front end, you need to hide the qty since you don't want the end-user to change it (now the system thinks the qty = 0 and that's the trick) :
css trick (all forms within your site will be affected.You could go deeper within CSS to specify field with ID or even form_id=>field_id)
.ginput_quantity, .ginput_quantity_label {
display:none;
}
Stripe Feed - Subscription typeFront-end user form

Purch Agreement Header and Line view ax 2012

I am having this issue on PurchAgreement form, I create a new purchase agreement in the header view and when I go to line view (without saving this purch agreement ) it shows me all agreement Lines avalaible
Then when I save it they are empty as they should be, but I think it is wrong to show all the agreement lines while I still have not created the purchase agreement.
Is there any property or method that solves this?
This should only happen if you succeded to create agreement lines AgreementLine with zero value in the Agreement field. The zero agreement lines are auto dynalinked with the still zero RecId of the agreement header.
You should not be able to create such lines via the user interface as the field is mandatory.

Adding Quantity Change to Drop Down Menu

I am trying to make a pay now button for a registration form online. Each individual has two options for payment. If they are a member, they can pick and pay the member's rate for registering for this event. If they are not members, they will pick the public's rate option for it. That's fine. It works great and it will ask them to either pay the member rate or public rate.
My question is, I would like to add another drop down button which would allow them to change the quantity of tickets they buy to this event. So if they want to but 6 tickets, they select 6. And if they are not members, in the next drop down box, they select Public.
I can add the second drop down menu, but it doesn't affect pricing at all, doesn't change the quantity.
Any help?
If the price of each quantity is arbitrary, this can only be done with custom javascript.
Do your prices and quantities scale linearly? I.e. 1 for $10, 2 for $20, 3 for $30, 4 for $40 -- if so, you can use Add to Cart / Shopping Cart Buttons to handle the quantities.
Another potential hack is to multiply your current dropdown's number of entries with the number of your second menu.
General Public 1 ticket - $15
General PUblic 2 tickets - $25
Members Only 1 ticket - $10
Members Only 2 tickets - $20
Another way is to use 2 separate buttons, one listing the member rates and one listing the public rates. This might actually be the good-enough path of least resistance.

Access Report - Can't add a sum for a calculated currency column

I've generated a simple access report that is used for purchasing.
Basically, there are two tables, one for purchase orders, and one for the items on the purchase orders.
For the items on an order, I store the item details, quantity ordered, quantity delivered, and price per unit. (plus a few other fields which aren't relevant in the context of this question).
I'm generating a report to list all outstanding items still on order, and the report has a calculated field showing the outstanding quantity * cost per item. This works perfectly fine.
What I'm struggling with, is showing a sum of this calculated field (i.e. a total cost of all outstanding items), but when I try to add a total to the column, it only gives me the option of adding an item count for the column. The column is a 'Currency' field.
What might I be doing wrong, or am I expecting too much from access?
Resolved. I created the only option that the GUI would allow (item count), then modified the query from:
=Count(*)
to
=Sum([Quantity]*[Cost])
Works perfectly.

In Drupal 6 how do i automatically create CCK fields on a node when a new node of a referenced node type is created?

I'm using Drupal 6 and Views 2, along with CCK, Panels and Node Relationships. (so far)
I have two basic content types defined:
User Profile (using Content Profile module)
Product
Each of these content types has a node reference to two other content types, Tier and Commission:
User Profile content references "Tier" content
Product content references "Commission Category" content
There may be 5-10 of each of these, and up to 100 of each of users/products.
When a Commission Category is added, dollar values need to be added for each currently existing Tier node.
When a Tier node is added, dollar values for this Tier need to be added to each currently existing Commission Category node.
The desired effect is that users with a "staff" role can administrate both Tiers of users and Categories of Product.
Users will see a value when they view a product that is displayed as a combination of both their Tier and the Commission Category.
For Example:
Category A => Tier 1 ($100), Tier 2 ($200), Tier 3 ($300)
Category B => Tier 1 ($120), Tier 2 ($250), Tier 3 ($300)
Is there a way to do what I'm suggesting? or do I need to try a different approach altogether to achieve the desired effect?
I assume that you also want to be able to later edit those amounts from either the Tier node page or the Commission Category node page.
To make those values easier to manage, you will probably need to create another content type (called Commission for example) which references a Tier and a Commission Category, and holds a dollar value.
What I would do then is to use hook_form_alter() so that in the Tier form, an input field is added for each Commission Category. That way, whenever you add a new Tier (or edit an existing one), you can update all those values at once. Use hook_nodeapi() to insert/update all of the corresponding Commission nodes.
Then you can do the same thing for the Commission Category form, but in the other direction.
If you expect to have a large number of tiers or categories, this may be a heavy operation, but otherwise it should be fine since I'm assuming you wouldn't be changing these values that frequently.

Resources