How to show only products that are allowed to logged in user in Magento? - magento

In our current implementation of Magento, situation is as follows:
There are two types of products (items) under various categories.
1. Allowed to all
2. Allowed to specific logged in user (customer)
e.g. Let us assume that there are 100 items (under different categories) which are allowed to be shown to all logged in or not logged in users
Now there are 10 items which are allowed to be seen only by Customer A (Set A)
5 Items which are allowed to be seen only by Customer B. (Set B)
So when Customer A logs in, he/she will see all items that are allowed to all + Items from Set A but not from Set B.
When Customer B logs in, he/she will all items that are allowed to all + Items from Set B but not from Set A.
How can I achieve this result in Magento? Should I handle it in MySQL or within Magento modules?
Please suggest,
Thanks

Create Three attributes for each product.
allowedgroupA, allowedGroupB and allowedAll.
Now for products only for group B check allowedGroupB and for other two attributes done check.
Same for for products only for group A check allowedGroupA and for other two attributes done check.
products for all groups will have allowedAll as checked.
Now in your block code apply appropriate filter depending on customer logged in group.
Additional Comments:
Additionally if you have some product only for specific group or for all then just have one attributes.
allowedGroupId.
if allowedGroupId is set then its only for that specific customer group if its 0 then its for all customers.

Related

WC: Negative Stock from Order while Backorder is disabled

This is my problem: a customer bought a product that was out of stock. So the stock went from 0 to -1.
My out of stock threshold is at 0 and back ordering is disabled with all products.
I tried to recreate the scenario on my staging site but it was not possible to me. The product is greyed out and not selectable when I set its quantity to 0.
I thought maybe some caching issue (I'm using Hummingbird) prevented it from updating the stock. So these were the further scenarios I tried:
- selecting product on single product page, set stock in back-end to 0 --> not possible
- product in basket, set stock in back-end to 0 --> not possible
- product in checkout, set stock in back-end to 0 --> not possible
Would anyone of you know how it could have happened? I'm not sure how to proceed.
thanks
Jan
After carefully reading the WooCommerce source code I think you can recreate the problem if you have two computers.
Consider a product P with stock quantity equal to 1. There are 2 different customers A and B. Customer A puts product P into his cart. Before customer A places his order customer B puts product P into his cart. Then customer A places his order reducing the stock quantity of product P to 0. Then customer B places his order reducing the stock quantity of product P to -1. Unfortunately to test this it requires two computers (or two browsers) since you need two simultaneously logged in customers. I only have one computer and don't want to install another browser.
The problem is in the function WC_Cart::add_to_cart(). It calls WC_Product::has_enough_stock() with references to only the stock quantity of the product and the quantity ordered in its cart. It doesn't not take into account the quantities of the product that exists in other carts. In fact WooCommerce should be able to do better as it has knowledge of the contents of customer A's cart when customer B adds product P to his cart A.
Of course there is a bit of a dilemma here because if WooCommerce prevents customer B from adding product P to his cart because customer A has it in his cart and customer A doesn't actual place the order then the company may have lost a sale.
Alternatively, WooCommerce can reject customer B's order when B places the order but unless I missed something I did not see any code to do that. That would seem to me to be a reasonable solution.

How to limit number of order per customer for certain product? - Magento 1.9

I have a requirement in my website where the customer can buy a certain product only once. If they try to buy that again it should throw an error saying cannot purchase this again.
Please help me on this.
If it is only one or few products like that - the best way in my opinion is to add attribute to customer and change it after product is purchased.
Thanks for your question...
Solution:-
1- You've to create product attribute as Yes/No & by default, it'll be No.you've to select as Yes for the product which you want to avail purchase only once.
2- If a customer is logged in, then during Add to Cart if a product can purchase only once for a customer then before adding to cart(use observer here) you've to check if a customer already purchases this item if yes then you've to avoid
Add to Cart else customer can add this to cart.
3- If a customer is not logged in, in this case, it depends on you.
There may be 2 cases:-
a- Simply customer can be added to cart any item & after login, if a customer has added the restricted item(only once purchase) then you've to remove the restricted item from the cart if already purchased else vice versa.
b- OR you don't allow to Add To Cart(by an observer) restricted item if a customer is not logged in.
Hope it'll resolve your problem.

Magento Product Reviews only by customer who purchased the product

I searched everywhere, but could not find the solution for this. I want to not allow others except the buyers of that product to add review for that particular product, in Magento. Please can anybody help with this.
Initally make the option "Allow Guests to Write Reivews" to "No". Now, you can make this by taking the order collection of a particular product by getProductOrderCollectionById(). From that order collection we can get the list of the customers who purchased it.
In the other hand, you can get the ID of the logged-In customer. If the Order collection list contains the logged In customer ID, then you can allow them to display the review form.

how to give different access authority to different users credential in magento

I have client requirement that he want to me to make different prices list of products for different users, for example there will be two types of users one normal users and other one are doctors , so he want that if normal users come to this website then the price list should be different as for doctors, like for doctor a particular product rate can be 50 Rs but the same product for normal user is 70 Rs .
so i want to know can this be possible in magento and if "yes".
How to do it??????.
You could try to accomplish this using either
Customer Group
Multi Website
Third Party extension
Take a look #
Different prices for different groups? (wholesale prices, etc.)
Magento: How to Setup Simple Customer Specific Discount Pricing

What is the difference between the "Guest" and the "Not logged in" customer groups in Magento?

What is the difference between the following customer groups in Magento:
Guest
v
Not Logged In
To me these are both the same but when are each used? I believe this to be a source of a bug I am investigating as they both use different customer group id's 0 and 1 respectively.
Customer groups are simply a way of grouping customers that register, or are not logged in (in the case of the NOT LOGGED IN group only) on the store for things like assigning a tax band, and applying promotions.
The NOT LOGGED IN group is the only one which can apply to guests and cannot be edited or deleted. The names of all other groups is irrelevant, it's how you use that group when for instance creating tax rules, so if you have a group named Guest that is a custom group which has been created and can only apply to logged in customers (the only other default group created by Magento itself is called General).
See here for more info:
http://www.magentocommerce.com/wiki/welcome_to_the_magento_user_s_guide/chapter_6#creating_customer_groups

Resources