Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Example:
Buy any 3 "T-shirts", Get any 3 "Shorts" at 50% off.
or
Buy any 3 "Red" T-shirts, Get any 3 "Red" T-shirts at 50% off, where Red is a taxonomy term.
Comment | File | Size | Author |
---|---|---|---|
#9 | 2159655-9.bogo_category.patch | 34.68 KB | rszrama |
Comments
Comment #1
junetellain626 CreditAttribution: junetellain626 commentedComment #2
rszrama CreditAttribution: rszrama at Centarro commentedThis is basically an additional BOGO condition that would need to be added after Commerce Discount Extra is merged in.
Comment #3
michfuer CreditAttribution: michfuer at Centarro commentedThis is a patch for commerce_discount_extra. It creates two new offer types based on product categories. It's a bit heavy due to some refactoring of the install code to make offer types and their fields more manageable.
The term select list (product categories) is not grouped by vocabulary atm due to this issue https://www.drupal.org/node/1180992
Comment #5
joelpittetComment #6
joelpittetComment #7
rszrama CreditAttribution: rszrama at Centarro commentedOk, the refactoring of the .install file definitely should've come in a separate patch. I think it's good to go, but I did relegate the consideration of the uninstall hook to a separate issue to try to minimize the impact of this patch: #2663820: Uninstall Commerce Discount Extra field instances on module uninstallation
I did some light refactoring of the refactoring (function names, comments) and will review the new offer type itself ASAP. I also really can't imagine this working without some sort of hierarchy apparent in the term list, so we may need to retool that allowed values callback further. There are bound to be any number of terms that have the same name at different depths and as different subcategories in any decently sized product catalog.
Comment #8
rszrama CreditAttribution: rszrama at Centarro commentedWork in progress patch attached. Also, marking needs work as I know commerce_discount_extra_product_terms() needs to be optimized a little and have a query tag attached to its EFQ, and the action name and callback need to be changed to include "per_quantity" if possible. commerce_discount_extra_category is too vague.
Comment #9
rszrama CreditAttribution: rszrama at Centarro commentedOk, went through and confirmed the main feature itself worked (it does : ). I ended up changing some names of the offer types / functions / action so it was uniform with what we already had, but I made two other significant changes:
Attached and committed.
Comment #11
lelivero CreditAttribution: lelivero as a volunteer commentedHi rszrama, thanks for the work.
It's working when I fill in all the fields, but when I leave the field "On up to #" empty I get a general error. When I go back to the discounts overview my previously stored discount is even deleted.
I tested it on the "Per-quantity category discount ($ off)" and "Per-quantity category discount (% off)" options.
(Commerce Kickstart 7.x-2.33, Commerce discount v7.x-1.0-alpha7)
Comment #12
joelpittet@lelivero can you share the error message, it may be in your watchdog or system logs.
Comment #13
lelivero CreditAttribution: lelivero as a volunteer commentedYes, this is what I found in the log messages for every time I tried it:
PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'commerce_offer_limit_value' at row 1: INSERT INTO {field_data_commerce_offer_limit} (entity_type, entity_id, revision_id, bundle, delta, language, commerce_offer_limit_value) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6); Array ( [:db_insert_placeholder_0] => commerce_discount_offer [:db_insert_placeholder_1] => 23 [:db_insert_placeholder_2] => 23 [:db_insert_placeholder_3] => per_quantity_percentage [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => ) in field_sql_storage_field_storage_write() (line 514 of W:\sites\THseeds\wwwroot\modules\field\modules\field_sql_storage\field_sql_storage.module).
Comment #14
rszrama CreditAttribution: rszrama at Centarro commentedI can reproduce this. Let me look into it - not sure why the field and its form validation would differ off the top of my head.