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.
Having a Dress product type, how can I achieve this for SKU: DR-0001, DR-0002 for all entered dresses automatically as they are entered?
The number shall increase based on the number of nodes = actual products entered
Previously, with Auto NodeTiltle, and Token module, I could format this output using simple php code.
Comment | File | Size | Author |
---|---|---|---|
#4 | commerce_autosku-auto_serial_number-1216598-4.patch | 4.51 KB | kevinsiji |
Comments
Comment #1
rbayliss CreditAttribution: rbayliss commentedThis should be possible with a bit of custom code. You'll need a hook_token_info() and a hook_tokens() to provide a token that determines the product's id in the sequence (the 5th t-shirt, etc). I suspect this will be pretty similar to what you did for nodes previously.
Comment #2
Salman_Rahma CreditAttribution: Salman_Rahma commentedThank you for your suggestion. The PHP code I used before was only for formatting the output and I had copied from some site. unfortunately I am not a coder and I think this would be a nice feature to be added out of the box for the module.
Comment #3
kmolkens CreditAttribution: kmolkens commentedI have a similar request.
It would be interesting to have the possibility to add a Pattern for the SKU based on custom PHP code.
In Drupal6/Ubercart, I used Product Power Tools allowing a field for entering PHP code.
This is very useful to calculate a SKU used for barcode scanning.
The code calculates a sku conform to EAN-8 or EAN-13 or ... barcode numbers (including checksum,...).
Comment #4
kevinsiji CreditAttribution: kevinsiji commentedHere is a patch.
This will also provide a facility to decide the starting number.
You can provide the static part of the sku in the token pattern (a real token is not necessary) and the starting number in the textbox provided under the 'Advanced' fieldset.
Criticize this patch, so that I will learn my mistakes.
Comment #5
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedI would like an option to add this to the end of my tokenized autosku value.