|
Our web application is almost complete with one exception. The shopping cart is not user based, more like it is a global cart; a product added by one user can be seen and deleted by another. So we have to avoid that.
Steps:
| 1. | Open the "Products" page. |
| 2. | Locate the "InsertToCart" process element and double click onto it. |
| 3. | Modify the SQL query as folllows |
selecT COUNT(*) AS v:CNT FROM cart WHERE PRODUCT_ID = @vof(ID) AND USER_ID = @vof(/mor_security_userinfo_main.id);
@doif(v:CNT > 0)
UPDATE cart SET
QUANTITY = QUANTITY + 1
WHERE PRODUCT_ID = @vof(ID);
@doelse()
INSERT INTO cart
(PRODUCT_ID, QUANTITY, USER_ID)
VALUES (@vof(ID), 1, @vof(/mor_security_userinfo_main.id) );
@doend()
|
| 4. | Open the "CurrentOrder" page. |
| 5. | Locate the data source element "cart_products" and double click onto it. |
| 6. | Modify the SQL query as folllows |
SELECT
c.ID, c.PRODUCT_ID, c.QUANTITY,
p.NAME, p.PRICE,
p.PRICE * c.QUANTITY as LINETOT
FROM
cart c, products p
WHERE
c.PRODUCT_ID = p.ID AND c.USER_ID = @vof(/mor_security_userinfo_main.id)
|
"/mor_security_userinfo_main.id" variable is provided by the Securtiy component and it returns the id of the current user.
|