Closed (fixed)
Project:
Ubercart Price Per Role
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
26 Jan 2011 at 16:14 UTC
Updated:
29 Sep 2011 at 22:01 UTC
Jump to comment: Most recent file
Comments
Comment #1
MPeli commentedI have tried to convert these functions:
This is my first try to create a module :) So be patient please.
Comment #2
MPeli commentedI have made some progress.
Comment #3
MPeli commentedAttached port allows you to set different prices for different roles. I am stuck and do not know how to continue, especially with part "Optional prices".
Comment #4
longwaveI realised I've neglected Price Per Role for some time, so many thanks for posting this; I'll review it when I find some free time, or maybe someone else can step in to help out with a review as well.
After a quick look at the code just now, it would be helpful if you could ensure the Drupal coding standards are followed - use two spaces instead of tabs, and run your code through Coder module - and also if you could post patch file(s) instead of zips.
Comment #5
MPeli commentedA new development version is attached. I have run it through Coder module. As soon as I learn how to create a patch I will do it. Sorry for the zip file. Would it be possible to create official release? Something like Ubercart Price Per Role 7.x-alpha1? I think it would speed up the whole development process.
Thanks, Martin.
Comment #6
MPeli commentedI have made some progress.
This function is not being executed and I do not know exactly why.
uc_price_per_role_cart_item($op, &$item)
Comment #7
longwaveI think the hook has been renamed in Ubercart 7.x-3.x, so the function should now be called uc_price_per_role_uc_cart_item.
I will create a 7.x-3.x-dev branch once I've found some time to review and commit your code. Thank you for your work on this!
Comment #8
MPeli commentedThanks! You are right. The function has been renamed. A new version is attached.
Comment #9
shadowmihai commentedsubscribe
Comment #10
shadowmihai commentedIs there any further development on this module? I can help test on my site(s) (but I cannot program... php illiterate, really...)
Comment #11
pglatz commentedThanks for starting the 7 port; this is a module I really need. I was able to create a role and add a different price for a wholesale user. Terrific!
I found a few of issues I wanted to point out:
1) Calls to install/uninstall the schema are not required in the .install files in Drupal 7, and will generate an error. Here's what I did:
uc_price_per_role_install()
remove call to drupal_install_schema()
uc_price_per_role_uninstall()
remove call to drupal_uninstall_schema()
2) When I create a product, I see these notices:
Notice: Undefined property: stdClass::$roleindependent_sell_price in uc_price_per_role_node_prepare() (line 330 of uc_price_per_role\uc_price_per_role.module).
Notice: Undefined property: stdClass::$role_prices in uc_price_per_role_form_alter() (line 180 of uc_price_per_role\uc_price_per_role.module).
Notice: Undefined offset: 1 in uc_price_per_role_form_alter() (line 182 of uc_price_per_role\uc_price_per_role.module).
Notice: Undefined offset: 2 in uc_price_per_role_form_alter() (line 182 of uc_price_per_role\uc_price_per_role.module).
Notice: Undefined offset: 3 in uc_price_per_role_form_alter() (line 182 of uc_price_per_role\uc_price_per_role.module).
Notice: Undefined property: stdClass::$nid in uc_product_get_shipping_type() (line 495 of ubercart\shipping\uc_quote\uc_quote.module).
Notice: Undefined property: stdClass::$nid in uc_product_get_shipping_type() (line 495 of ubercart\shipping\uc_quote\uc_quote.module).
3) I then created a wholesaler role, and enabled it in the config. This took care of some of the notices; this is what I see now:
Notice: Undefined property: stdClass::$roleindependent_sell_price in uc_price_per_role_node_prepare() (line 330 of uc_price_per_role\uc_price_per_role.module).
Notice: Undefined property: stdClass::$role_prices in uc_price_per_role_form_alter() (line 180 of uc_price_per_role\uc_price_per_role.module).
Notice: Undefined property: stdClass::$nid in uc_product_get_shipping_type() (line 495 of ubercart\shipping\uc_quote\uc_quote.module).
Notice: Undefined property: stdClass::$nid in uc_product_get_shipping_type() (line 495 of ubercart\shipping\uc_quote\uc_quote.module).
I don't have the time today to dig much further, but I am a module developer, and might be able to give some suggestions. I'm fairly new to 7 but am trying to use it for all new work.
If this isn't going to be an official port yet, you can always create your own repository for free at github, if you are interested in working with others on this. Much easier to coordinate than zip files!
Good work, it is working fine for me. The notices are the only problem I'm seeing right now, and they can probably be eliminated with a few simple variable checks.
Comment #12
hozt commentedThanks for doing the work on this.
I was getting a notice when viewing a product about an invalid index. I fixed this by changing line #360
Comment #13
MPeli commentedHi,
I have tried to create a repository at github - https://github.com/MPeli/Ubercart-Price-Per-Role Unfortunately, I was not able to upload any files. When I try to upload something a get error 404.
#180
#330
Comment #14
hozt commentedThis is getting closer to working. There are a couple of remaining issues:
1) After you enter a role based price on a product and save the product all works well. If you edit the product again the role price will be blank. It looks like this is not a problem for attribute based pricing. Changing line #296 made it work for me:
#296
- $result = db_query("SELECT nid, rid, price FROM {uc_price_per_role_prices} WHERE vid IN(:vids)", array(':vids' => array_keys($nodes)));
+ $result = db_query("SELECT nid, rid, price FROM {uc_price_per_role_prices} WHERE nid IN(:nids)", array(':nids' => array_keys($nodes)));
2) The option to add additional roles prices does not show up for any custom product classes. I am not sure what the fix for this one is because the form_id for a custom product class will be something besides "product_node_form". Can we check for something else to confirm that we are editing a product type?
- if ($form_id == 'product_node_form') {
+ if (is_array($form['base'])) { // this works, but there must be a better way to check if we are editing a product
Comment #15
MPeli commentedHi,
I have made some changes have a look at the new version https://github.com/MPeli/Ubercart-Price-Per-Role
I do not face the problem you described in point number 1) that is why I did not implement suggested changes. Do you use the latest version of Ubercart?
I modified function uc_price_per_role_node_load() as well.
Martin.
Comment #16
duaelfrI have done a pull request on github to correct a tiny mistake
I will try your module now
Thank you for this great work
Comment #17
duaelfrIt seems to work well despite of the multiples notices.
I will pull a patch for it in a few seconds
Comment #18
eusofzay commentedWhy don't you list it as a dev version atleast.
Comment #19
eusofzay commentedI am getting this error when create a new product. If I have 5 roles then this notice is displayed 5 times.
Notice: Undefined offset: 1 in uc_price_per_role_form_alter() (line 188 of /home/hl7org/public_html/sites/all/modules/uc_price_per_role/uc_price_per_role.module).
Comment #20
eusofzay commentedNotice: Undefined property: stdClass::$role_prices in uc_price_per_role_node_insert() (line 333 of /home/hl7org/public_html/sites/all/modules/uc_price_per_role/uc_price_per_role.module).
Comment #21
davisbenI have rolled a patch against master that incorporates the latest code from MPeli's github repo with a fix for #19. I couldn't reproduce #20, anyone else seeing that error?
longwave - would you be interested in adding a co-maintainer for the 7.x branch?
Comment #22
davisbenOops, forgot the patch.
Comment #23
longwaveHuge thanks to everyone who's contributed to this. I've created a 7.x branch, based on #22 with the following changes:
Migrate integration is untested and probably needs work.
Download immediately from git, or wait a few hours for the 7.x-1.x-dev package to be built.
Comment #25
jcgarsan commentedHi guys!
First at all, good job!!!!
I'm trying to configure this module in Drupal 7x + Ubercart 3x, and I have this error:
Notice: Undefined index: #value en uc_price_per_role_form_alter() (line 213 of /var/www/tienda/sites/all/modules/uc_price_per_role/uc_price_per_role.module).
So, it appears one error for each product I have in the store. Any suggestion?
Many thanks!!!
Comment #26
duaelfr@jcgarsan
Sorry but I have no IDE nor Git on this computer to provide a patch.
In the file uc_price_per_role.module
Replace the line 213
By
Comment #27
conkdg commentedSubscribe
Comment #28
jcgarsan commentedHi DuaelFr,
I've tried your trip but it doesn't work. Now it appears this error:
Notice: Undefined variable: qty in uc_price_per_role_form_alter() (line 217 de /var/www/tiendaleds/sites/all/modules/uc_price_per_role/uc_price_per_role.module).
I think the problem is in the database table, where it doesn't appear the "qty" colum, may it be possible?
Many thanks for your help!!
Comment #29
duaelfrIt is not a real bug but just a warning from PHP.
Try replacing
By
The modules' database tables are not supposed to have a "qty" column. This field might be in the "add to cart" form to allow the user to add more than one product to his cart but this option may be disabled in your shop.
Comment #30
jcgarsan commentedHi DuaelFr,
I see... so that's not a bug... so maybe, it'd be necessary to check the other functions and find out why this function fails. I've made your last modification and the warning is still there... If that's a warning, is there any possibility to avoid it?
I'll try to take a look around and follow the 'qty' variable, in order to get more information.
Once again, thanks for your help and if you have any suggestion more or any idea to test, tell me!!
Thanks!!!
PS: i'm a newbie in Drupal.... :S
Comment #31
duaelfrHi,
Warnings can be hidden by editing the error_level var in php.ini
While warnings are not errors, your site will be flly functional if you hide them.
Comment #32
jcgarsan commentedHi friends,
I'm not sure but I think I've found a solution. I think the problem is the #value tag. Can anyone try to confirm if this mod works fine?
Initial modification:
if (isset($form['qty'])) {
$qty = intval($form['qty']['#value']);
}
My modification:
if (isset($form['qty'])) {
$qty = intval($form['qty']['#default_value']);
}
What do you think about??
Comment #33
duaelfrThe result will depend on your uc configuration.
If quantity field is a textfield or a select box (I don't remember) so the correct key will be #default_value
If the field is hidden, the correct key will be #value
http://api.drupal.org/api/drupal/developer--topics--forms_api_reference....
Comment #34
jcgarsan commentedHi all!!
DuaelFr, many thanks for your help. I think the "problem" has been solved using the key #default_value, as well as you mention, my quantity field is a textfield.
Once again, thank you and good job!!!
jcgarsan