commerce per user price module for Drupal 7.x.
This module provide per product per user price for Drupal Commerce from custom database table product_price_list.
Suppose we have 3 user and 4 products in site then the per product per user price would be 3*4=12.
Many User facing such kind of problem here https://drupalcommerce.org/questions/7580/user-pricing is the article where I see users comment so that's why I developed this module.
Instruction to download
Project page link https://www.drupal.org/sandbox/arvind.kinja/2469271
git clone --branch 7.x-1.x https://git.drupal.org/sandbox/arvind.kinja/2469271.git commerce_per_user_price
REQUIREMENTS
------------
*Drupal Commerce
INSTALLATION INSTRUCTIONS
-------------------------
1. Copy the module in your Drupal sites/all/modules directory.
2. Login as site administrator.
3. Enable the Custom module on the Administer -> Modules page
(Under the "Commerce (contrib)" category).
4. Go to admin/commerce/config/custom_price to view price table.
You can add record manually from here admin/commerce/config/custom_price/add .
5. This module create custom table in database product_price_list. Insert price in our custom table.
Suppose we have three user in site haveing id 1,2 and 3. We have 2 product in site haveing id 1 and 2
The format should be
id, product_id, user_id, price
1, 1 , 1, 42
2, 2 , 1, 23
3, 1 , 2, 49
4, 2 , 2, 36
5, 1 , 3, 12
6, 2 , 3, 22
MANUAL REVIEW OF OTHER PROJECTS
https://www.drupal.org/node/2643506#comment-10784962
https://www.drupal.org/node/2644054#comment-10788346
https://www.drupal.org/node/2645742#comment-10794590
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | custom_price.png | 25.89 KB | arvind.kinja |
Comments
Comment #2
PA robot commentedFixed the git clone URL in the issue summary for non-maintainer users.
We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #3
arvind.kinjaComment #4
arvind.kinjaComment #5
arvind.kinjaComment #6
arvind.kinjaComment #7
arvind.kinjaComment #8
eternallight commentedHi,
I've been testing your module, read through the source code, and here are some things I noticed.
1. Lowercase module name
name = commerce per user priceYou probably want to capitalize each word of the name, so that it looks similarly to the other modules (Commerce per User Price).
2. In your hook_menu():
'access callback' => 'user_access',You do not need this line since 'user_access' is the default access callback.
3. 'Custom Price Override' role.
In order to apply a custom price to a user, you require it to have your hardcoded role, which may be annoying. If there are no other ways, I suggest you to create this role programmatically in your hook_install() and remove it in hook_uninstall().
4. When attempting to add a price rule, got an error:
Fatal error: Call to undefined function drupal_set_messages() in /var/www/sandbox/sites/all/modules/commerce_per_user_price/commerce_per_user_price.module on line 135This function's correct name is 'drupal_set_message'.
5. When attempting to submit the custom form price with dummy text values, got an error:
PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'asgfsg' for column 'user_id' at row 1: INSERT INTO {product_price_list} (product_id, user_id, price) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => sgsag [:db_insert_placeholder_1] => asgfsg [:db_insert_placeholder_2] => fasfsa ) incommerce_per_user_price_form_submit() (line 133 of/var/www/sandbox/sites/all/modules/commerce_per_user_price/commerce_per_user_price.module)This is actually a security hole since anything from the inputs goes directly to the database. You should add '#element_validate' => array('element_validate_integer_positive') to each commerce_per_user_price_form element. Also, add some advanced validation in 'commerce_per_user_price_form_validate' to make sure that user and product with entered IDs actually exist in the database.
By the way, form keys like 'product-id' or 'user-id' look weird to me. Typically, underscore is used.
6. Wrong hook annotations.
It's hook_commerce_cart_line_item_refresh.
It's hook_commerce_product_calculate_sell_price_line_item_alter.
Comment #9
arvind.kinjaHi EternalLight,
Thanks for review my code.
I made all the changes that you mentioned above.
Regards
Arvind
Comment #10
laurent23 commentedThank you for the code, i tried it and works nice, it really helps me so please continue the good work.
Cheers!
Comment #11
PA robot commentedThere are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxarvindkinja2469271git
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #12
arvind.kinjaHi, i fixed all error that comes through automated review tools.
Comment #13
arvind.kinjaComment #14
brijendra1985 commented+1 for this module. I found it today and this seems like a pretty cool module.
Comment #15
arvind.kinjaHi brijendra1985, Thanks For review my project.
Comment #16
sjg12340 commentedI have been looking for a module like this for some time. My developers say the code is good and we are installing it now. Thanks Arvind, just what we wanted.
I will keep you posted how we get on but all looks excellent so far.
Thanks,
Comment #17
arvind.kinjaComment #18
arvind.kinjaHi sjg12340,
Thanks for review my project.
Regards
Arvind
Comment #19
spacetaxi commentedManual Review
The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.
If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.
This review uses the Project Application Review Template.
Comment #20
arvind.kinjaComment #21
arvind.kinjaHi spacetaxi,
Thanks for review my project.
I fixed all the point that you described above.
Comment #22
spacetaxi commentedHello arvind.kinja, I reviewed again.
* I think that you need to remove the access checks in functions commerce_per_user_price_commerce_product_calculate_sell_price_line_item_alter and commerce_per_user_price_commerce_cart_line_item_refresh so that there isn't an access check, but would simply implement the new price if available and default to the normal price if not set by your module. As it stands now, someone would need access to both set these prices in order to be the beneficiary of the custom prices, which I don't think is what you intended.
Documentation formatting is better, but still isn't very clear. If you get this to project status, I'll rewrite for you.
* There is still the question of whether this module duplicates functionality of https://www.drupal.org/project/commerce_pricelist. Do you want to address this?
Comment #23
arvind.kinjaHi spacetaxi,
Thanks for giving me guideline on project.
* I removed security check in both function commerce_per_user_price_commerce_product_calculate_sell_price_line_item_alter and
commerce_per_user_price_commerce_cart_line_item_refresh.
* I added more instruction in the documentation to make it more clear.
* I checked module https://www.drupal.org/project/commerce_pricelist and does not have duplicate functionality. My module simple and easy to use. Many user facing problem here is the article https://drupalcommerce.org/questions/7580/user-pricing
Comment #24
arvind.kinjaComment #25
spacetaxi commentedI'm moving the status to reviewed and tested. Good luck with this.. Again, let me know if you need help with documentation later.
Comment #26
klausihm, looks like you forgot the review bonus tag? Adding it now.
Comment #27
arvind.kinjaHi klausi,
Thanks for review my project.
Is their anything that I have to complete?
Regards
Arvind
Comment #28
klausiReview of the 7.x-1.x branch (commit a980374):
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.
manual review:
Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.
Comment #29
arvind.kinjaHi klausi,
I fixed code sniffer issues according to drupal coding standard.
I added foreign keys in commerce_per_user_price_schema().
I changed price field and will be stored as integer.
Comment #30
arvind.kinjaComment #31
klausinow revealing the security vulnerability: the path /custom_price/%/delete is vulnerable to CSRF exploits. You need to either use a confirmation form or CSRF tokens on GET requests. See http://epiqo.com/de/all-your-pants-are-danger-csrf-explained and https://docs.acquia.com/articles/protecting-your-drupal-module-against-c... .
Comment #32
arvind.kinjaHi klausi,
Thanks for guide me to fix security issues in module.
I added drupal confirmation form in the custom_price/%/delete path.
Comment #33
arvind.kinjaComment #34
arvind.kinjaManual review of 3 another projects:-
https://www.drupal.org/node/2756909#comment-11398441
https://www.drupal.org/node/2765647#comment-11398313
https://www.drupal.org/node/2747701#comment-11394919
Comment #35
arvind.kinjaComment #36
klausiFixing tag.
Comment #37
arvind.kinjaHi All,
Its over 2 month and I am not getting no more reviews. How much time it will takes to get more reviews or account approval to promote my project from sandbox to full project.
Regards
Arvind
Comment #38
klausimanual review:
Although you should definitely fix those issues they are not critical application blockers, otherwise looks RTBC to me.
Assign to Naveen as he might have time to take a final look at this.
Comment #39
arvind.kinjaHi klausi,
I fixed all the point.
Path user_id/autocomplete and product_id/autocomplete is already protected with "commerce per user price" permission.
Comment #40
klausino objections for more than a week, so ...
Thanks for your contribution, Arvind!
I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thanks to the dedicated reviewer(s) as well.