1

I'm using Drupal Commerce and would like to develop an online photo printing service like shutterfly.com and snapfish.com.

I wonder if it's possible using customizable products to count each uploaded file/photo and charge accordingly? If not, what other way can I achieve this requirement?

0

The answer is "yes"

I originally posted the answer here: https://drupalcommerce.org/questions/16291/can-customizable-products-work-out-price-based-number-uploaded-files

Export of the rule that proves it's possible:

   { "rules_files_price_multiplier" : {
      "LABEL" : "Files Price Multiplier",
      "PLUGIN" : "reaction rule",
      "OWNER" : "rules",
      "REQUIRES" : [ "rules", "commerce_line_item", "commerce_product_reference" ],
      "ON" : { "commerce_product_calculate_sell_price" : [] },
      "IF" : [
        { "entity_is_of_type" : { "entity" : [ "commerce-line-item" ], "type" : "commerce_line_item" } },
        { "entity_has_field" : {
            "entity" : [ "commerce-line-item" ],
            "field" : "field_upload_all_the_files"
          }
        },
        { "list_count_is" : {
            "list" : [ "commerce-line-item:field-upload-all-the-files" ],
            "op" : "\u003E",
            "value" : "0"
          }
        }
      ],
      "DO" : [
        { "variable_add" : {
            "USING" : { "type" : "integer", "value" : "1" },
            "PROVIDE" : { "variable_added" : { "file_multiplier" : "file_multiplier" } }
          }
        },
        { "LOOP" : {
            "USING" : { "list" : [ "commerce-line-item:field-upload-all-the-files" ] },
            "ITEM" : { "list_item" : "Current list item" },
            "DO" : [
              { "data_calc" : {
                  "USING" : { "input_1" : [ "file-multiplier" ], "op" : "+", "input_2" : "1" },
                  "PROVIDE" : { "result" : { "result" : "Calculation result" } }
                }
              },
              { "data_set" : { "data" : [ "file-multiplier" ], "value" : [ "result" ] } }
            ]
          }
        },
        { "commerce_line_item_unit_price_multiply" : {
            "commerce_line_item" : [ "commerce_line_item" ],
            "amount" : [ "file-multiplier" ],
            "component_name" : "fee",
            "round_mode" : "1"
          }
        },
        { "drupal_message" : { "message" : "[commerce-line-item:line-item-id]: File Multiplier = [file-multiplier:value]" } }
      ]
    }
  }

NOTE: This will still not update the price as the person is uploading files.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.