I'm still trying to figure out how to use this module, so I might be missing something fundamental, but is there a way (without hacking the module) to allow subscription periods less than one week?

I'm working on an exam/training type site and want to allow a one-day subscription. I tried using a decimal in the "weeks" field for the product, but that field is limited to integers.

Sort of related: I'm still getting my D7 legs under me. Is there an interface somewhere to modify the fields (like "weeks") on the product type? Presumably, it was set up that way before being exported as a Features module, but I've only been able to find the fields interface for nodes/comments/taxonomies/users.

Comments

amirtaiar’s picture

Will be happy for this issue to get done as well...

Dimanic’s picture

Change weeks to days in code is the best solution for this case.

mrconnerton’s picture

Title: Is it possible to specify subscription periods less than a week? » Add more subscription period options

I think this needs to be two fields:
1) Subscription Units: days, weeks, months, year
2) Subscription Period

The rule can manage the math and these two fields will manage just about any subscription period you can think of.

marcoka’s picture

Category: support » feature

i think in general the value should be in days and not in weeks. this provides more flexibility and you would still be able to add week values (just 52 weeks * 7 days ..) but the other way around is not possible.

marcoka’s picture

i think a change in .module would make it possible to use days instead of weeks.

we have two functions here setting and getting the value

ORIGINAL

/**
 * Gets the duration in seconds.
 */
function commerce_sp_time_get($entity, array $options, $name, $entity_type, $info) {
  $weeks = entity_metadata_field_property_get($entity, $options, $name, $entity_type, $info);
  return $weeks * 7 * 24 * 3600;
}

/**
 * Sets the duration in seconds.
 */
function commerce_sp_time_set($entity, $name, $value, $langcode, $entity_type) {
  $value = $value / (7 * 24 * 3600);
  $weeks = entity_metadata_field_property_set($entity, $name, $value, $langcode, $entity_type);
}

ORIGINAL

/**
 * Gets the duration in seconds.
 */
function commerce_sp_time_get($entity, array $options, $name, $entity_type, $info) {
  $days = entity_metadata_field_property_get($entity, $options, $name, $entity_type, $info);
  return $days * 24 * 3600;
}

/**
 * Sets the duration in seconds.
 */
function commerce_sp_time_set($entity, $name, $value, $langcode, $entity_type) {
  $value = $value / (24 * 3600);
  $days = entity_metadata_field_property_set($entity, $name, $value, $langcode, $entity_type);
}
marcoka’s picture

if fargo agrees to this i can make a patch? lets wait for his opinion

pingevt’s picture

Has there been any movement on this? I need this for a project. I'll be happy to commit a patch as soon as I get it done, unless someone else has already done it.

My plan, as is stated in comment 3 is to simply add another field so each product can choose days, months, weeks or years. This is my clients requirements, and I think is most flexible overall.

pingevt’s picture

My misunderstanding the 2.x version of this module takes care of this.

bessone’s picture

Version 2.x seems bit frozen, no updates on commit this in 1.x?

markusa’s picture

2.x has this functionality but you have to use git to download it from drupal.org

mrconnerton’s picture

Status: Active » Fixed

This is implemented in the 2.x version using the interval module. You can checkout that version using git or grab a snapshot from drupalcode.org/project/commerce_sp. The current snapshot is http://drupalcode.org/project/commerce_sp.git/snapshot/8ad50082a7aa36af6...

You will need to make sure you have features 2.x, at least rules 2.2, and apply this patch http://drupal.org/node/1522018#comment-7257988

I kept the status at fixed instead of closed(fixed) in case someone wants to attempt to port the interval stuff to 1.x

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.