How to cache invoices per user in Rails - ruby-on-rails-3

I have an app where a user can signup, create a customer, then create an invoice for that customer. The invoice has lineitems and images attached.
Now I want to use action caching and fragment caching on the invoices. How should I name the fragment caches so that they're only used for that specific user? (Using devise). I was thinking of putting the Invoice ID and User ID inside the cached fragment name, is that the "Rails" way of doing this?

Related

Restrict customers being able to view a category/plp

What is the suggested approach to restrict a customer viewing a PLP, based on the user group assigned to the CategoryModel?
For example, let's say a category with code "c012345" is assigned to the user group "promoPreviewCustomers". I have two registered customers who are a part of the customergroup but only one customer is in the promoPreviewCustomers group.
Only the customer who is in a promoPreviewCustomers group, should be able to see the PLP of the category page c012345.
Our initial thought was to drive this through a personalisation rule within Commerce.
What are other people's thoughts on how this should be implemented within Spartacus, given that the product search API does not take into account the logged in customer?
Any restriction done only in Spartacus will be only for the UX as true restriction can only be done in the backend. Therefore, the best approach would be to drive this behavior with personalization within Commerce

How to add own modules in Shopify?

I Want to create my own customized modules in Shopify when customers is logged in.
Example: I would to show near by doctors through the map.
Is it possible to do in Shopify.
Yes it is. You would install a custom App that would contain a list of doctors and locations. You would create a Proxy in the App so you could make a secure callback to the endpoint. As data, you'd send the customer ID. Using the customer ID, the App would get the customer's location. The data you return would be the matching doctors.
Very common to do this with Shopify.

How to verify that guest email is already exist as customer in system on checkout page in Shopify

We need to add feature in Shopify that guest/customer can't purchase the product more then limit defined in product meta field in CMS.
Basically, we have limited edition of product so want that single person [email verification] can purchase 1-2 quantity in life time.
For this we tried following ways:
Webhook: But not able to find solution to show error on checkout page and stop order if we found such condition.
Custom code on template itself: But we are not able to verify email from CMS that its already attached to a customer otherwise we will get all orders of that customers and then products and matched with current cart product and show error message
Don't allow guest checkouts. Force your customers to login with an email. Them you can be certain of not allowing them to checkout with more than the one or two of these products in their lifetime. Otherwise, accept their order and simply cancel/refund the cheaters.

Design pattern for maintaining different state(s) across browser tabs in a single session

I have an MVC 4 based web app. Where I provide 2 login types, 1. Employee and 2. Customer. With Customer login, I present a dashboard and other stuff, about his orders, etc. With Employee login, I allow the employee to search for his customers and provide the ability to carry out certain customer specific tasks.
It is possible that, an employee after login can seach for a number of customers and fetch each of their details in multiple browser tab(s).
I am having difficulty in maintaining state for each tab, if I put the unique identifier of the customer in session, as the next subsequent request will overwrite the session!
To solve this, I have relied on a (dirty) viewbag based solution, where I set the customer number in viewbag in every view.
Is there an elegant solution to solve this? a known design pattern?

Dwolla Custom Payment Buttons: Where does the data go?

I'm currently integrating a Dwolla payment method hack on a Shopify store using a Dwolla button. The explanation of the hack is posted on the Shopify forums here:
http://ecommerce.shopify.com/c/shopify-discussion/t/has-shopify-and-you-abandoned-dwolla-133714
(The hack is being used because Shopify doesn't currently support a viable Dwolla gateway option)
I finally did a live test in both guest checkout mode and checked out with an account signed in to Dwolla.
I don't see any of the transaction details when viewing the payment in my Dwolla account(the detail field is empty) despite having included the following button parameters:
data-amount
data-shipping
data-tax
data-name (populated with the Shopify order #)
data-desc (populated with the Shopify Customer Name from Checkout)
data-orderid (populated with the Shopify order #)
data-notes (populated with the customer's checkout note from the Shopify checkout)
data-guest-checkout (true)
I had incorrectly assumed that data-name, data-desc, and/or data-orderid would populate information in the Dwolla transaction information in my Dwolla account's Payment Activity under Options:Details for the transaction.
My question is this: What happens to the data-name, data-desc, data-orderid information?
Is it retrievable on the Dwolla side?
Is there some way to populate the transaction details with any of the above identifiers?
Clarification: When the customer arrives on the Dwolla secure payment page the identifiers do populate the fields properly. My concern is that as the merchant, when I view the transaction in my business Dwolla account, there is no information that links the transaction to the Shopify order by either the order# or a matching customer name (if the name entered in the Dwolla payment process was different than the name entered in the Shopify checkout process).
The only field that is viewable in the Transaction Details page of Dwolla.com is the data-notes. So, if you'd like to be able to correlate transactions, I would suggest adding the Shopify order ID to the data-notes. The data-orderId field is viewable in the Transactions/ById() API call.
The data-name and data-desc, as you've already discovered, are only used at the time of checkout to list the products purchased.