Hi,
I have found this module after searching for possible alternatives to MS Scripts Pay to Publish module which seems to have been abandoned by its developer (although latest version of that module is near production stage)
There is no doubt in my mind that much of the code in MS Script modules was "borrowed" from Drupal Commerce modules it seems that at least in case of Pay to Publish module Commerce node checkout could "borrow" quite a bit.
For example:
allow for upgrades/downgrades between different plans
allow for promote to sticky or front page option on each plan
and so on...

Are there any plans to add above mentioned features?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

larowlan’s picture

Status: Active » Postponed

Hi
I have no plans to implement those features but you may be able to do something with commerce and rules as it is.
Happy to take patches too.
Lee

marty.true’s picture

+1 for these options.
I used to have a license for MS Pay to Publish and it does work well but now that Commerce is taking over and the Node Checkout module is doing a good job, would love to see it extended to have these options. In spare time, I'll work on extending it either with patches or Rules config.

Would love to see others contribute to the extension of this module to bring those options in.

jprstoney’s picture

Yep, I'd be interested in a 'pay to promote' feature.

jradpog’s picture

I managed to sort of get this to work with rules. Created a product in commerce called promote to front (for example) and then with commerce node checkout I added it to the node type I wanted. In rules I cloned the existing 'Publish the nodes that were purchased' rule and added a condition of 'order contains a particular product and put the SKU off this product name'. Then I added another action to the loop in the action section. This action being 'promote content to front page' with the parameter content:[node].

So this seems to work, but I noticed a downside with commerce_node_checkout. It renders the product options on the node/add page as a select box. i.e. only gives one option. So essentially you can't choose multiple products, say: 'sticky', 'promote to front', 'publish'. You would need to have product levels I guess. I.e. silver = publish, gold = publish and post to front etc. and then I haven't figured out a way where a user could upgrade their add at a later date and only pay for the 'promote to front' amount.

Any ideas how I could do this?
I

hoff331’s picture

Hi All,

This functionality can be implemented via rules. The following rule export will set the node to "promoted to front page" if the user purchases plan "PREMIUM". The rule is easily modified to set the node to "sticky at top of lists". Simply replace "PREMIUM" with the SKU of your publishing plan, and it works!

To import the rule, click rules > import rule.

{ "rules_if_plan_x_promote_to_front_page" : {
    "LABEL" : "If plan X promote to front page",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "9",
    "OWNER" : "rules",
    "REQUIRES" : [
      "commerce_order",
      "commerce_node_checkout",
      "rules",
      "commerce_checkout"
    ],
    "ON" : { "commerce_checkout_complete" : [] },
    "IF" : [
      { "commerce_order_contains_product" : {
          "commerce_order" : [ "commerce_order" ],
          "product_id" : "PREMIUM",
          "operator" : "=",
          "value" : "1"
        }
      }
    ],
    "DO" : [
      { "commerce_node_checkout_rules_nodes_from_order" : {
          "USING" : { "order" : [ "commerce-order" ] },
          "PROVIDE" : {
            "line_items" : { "line_items" : "Associated Line items" },
            "nodes" : { "nodes" : "Associated Nodes" }
          }
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "nodes" ] },
          "ITEM" : { "node" : "Nodes" },
          "DO" : [ { "node_promote" : { "node" : [ "node" ] } } ]
        }
      }
    ]
  }
}
hoff331’s picture

Status: Postponed » Needs review

Please test this rule export, if it works as expected perhaps it can get added to the Node Commerce Checkout module.

Agiss’s picture

Hi guys,

I am going to invest some money on extending this module's functionality by adding multiple pricing options to products.

e.g.

a. Product price:£1
b. Product option 1 (Promote Ad to home page) price: +£1
c. Product option 2 (Stick Ad to top of lists) price: +£1Product option 3 (Enter discount code): either –20% or - £1
d. Products and product options filterable in views.
e. Enable nodes to be published without completing the checkout process if product’s price is 0 i.e. when a product’s price is set to 0, or price has been reduced to 0 after a discount.
etc...

If you're willing to contribute please follow the project on peopleperhour.com website

https://www.peopleperhour.com/job/view?id=842983&jobview=1

I look forward to your support.

Thanks
Agis

flaw’s picture

hoff331,
I've tried that rule and it works fine, thanks!

Is there a way to have the commerce node checkout field visible on the form after a user has created the node? so that a user can upgrade their plan after creating the content?
At the moment, once a node is created, the commerce node checkout field is removed from the edit form.

dimaboychev’s picture

Component: Miscellaneous » Code
FileSize
9.43 KB

1. After applying the patch, update the module by running “drush updb” or by going to http://your_site/update.php
2. Edit your “Pay to publish” product(s) which should be listed under ‘/admin/commerce/products’
3. You will see two new fields “Sticky Price” and “Promote Price”. Enter desired prices in the fields, enter “0” for a field you don’t want to use or want to make it free if later on you choose that field to be available in your node (step 4).
4. Edit the content type you previously used for Commerce Node Checkout and go to “Commerce Node Checkout” tab. There you will see two new options “sticky” and “promote”. Select both or the one you would like to be available in your node.
5. Go to “Publishing options” tab and make sure Sticky and/or Promote are NOT checked.

If installing the module for the first time with this patch follow steps 2 - 5, but instead of editing you will be creating new product(s) and content type(s).

P.S.
Need to display price next to sticky and promote. Forgot to do this.

larowlan’s picture

Status: Needs review » Needs work
  1. +++ b/commerce_node_checkout.install
    @@ -171,5 +194,28 @@ function _commerce_node_checkout_installed_instances() {
    +// This update hook allows addition of sticky/promote feature by simply updating the module
    

    nit: > 80

  2. +++ b/commerce_node_checkout.module
    @@ -148,6 +154,22 @@ function commerce_node_checkout_process_element($element) {
    +    if ($ct_option[0] == 'Sticky') $desc = t('Enhance your listing by making it sticky at top of lists.');
    +    if ($ct_option[0] == 'Promote') $desc = t('Enhance your listing by promoting it to the front page.');
    

    Please use multi-line ifs, not short syntax.

    Also, please use ===

    I think we need to make these strings configurable on a per-content type basis.

  3. +++ b/commerce_node_checkout.module
    @@ -163,6 +185,10 @@ function commerce_node_checkout_get_node_type_enabled_products($type) {
    +function commerce_node_checkout_sticky_promote($type) {
    +  return variable_get('enable_sticky_promote_' . $type, array());
    

    No need for a wrapper here

  4. +++ b/commerce_node_checkout.module
    @@ -222,6 +248,16 @@ function commerce_node_checkout_get_node_type_product_list($type) {
    +function commerce_node_checkout_get_node_sticky_promote($type) {
    +  if ($enabled = commerce_node_checkout_sticky_promote($type)) {
    +    foreach ($enabled as $value) {
    +      $node_option[] = $value;
    +    }
    +  return $node_option;
    +  }
    +  return FALSE;
    +}
    

    Needs a docblock and phpcs indenting fixes

  5. +++ b/commerce_node_checkout.module
    @@ -259,7 +295,16 @@ function commerce_node_checkout_add_node($node, $product) {
    +    if (isset($node->commerce_node_checkout_product_options['Promote'])) {
    +      $line_item->commerce_node_checkout_promote[LANGUAGE_NONE][0]['value'] = $node->commerce_node_checkout_product_options['Promote'] ? 1 : 0;
    ...
    +    if (isset($node->commerce_node_checkout_product_options['Sticky'])) {
    +      $line_item->commerce_node_checkout_sticky[LANGUAGE_NONE][0]['value'] = $node->commerce_node_checkout_product_options['Sticky'] ? 1 : 0;
    

    Can we use constants for 'Promote' and 'Sticky' - thanks

  6. +++ b/commerce_node_checkout.module
    @@ -326,9 +371,64 @@ function commerce_node_checkout_get_order_products($order) {
    +  if($line_item->type == 'commerce_node_checkout') {
    

    Please use ===, and should be space after first (

  7. +++ b/commerce_node_checkout.module
    @@ -326,9 +371,64 @@ function commerce_node_checkout_get_order_products($order) {
    +        // required as well to keep order total in sync
    +        $line_item->commerce_unit_price[LANGUAGE_NONE]['0']['data']['components']['0']['price']['amount']=$price;
    

    nit: fails phpcs

  8. +++ b/commerce_node_checkout.module
    @@ -326,9 +371,64 @@ function commerce_node_checkout_get_order_products($order) {
    +function commerce_node_checkout_commerce_checkout_complete($order) {
    

    Shouldn't this happen when the publish happens?

dimaboychev’s picture

marty.true’s picture

Status: Needs work » Needs review
larowlan’s picture

Issue tags: +Needs tests
  1. +++ b/commerce_node_checkout.install
    @@ -37,6 +39,11 @@ function commerce_node_checkout_install() {
    +function _commerce_node_checkout_create_fields() {
    

    This function needs a docblock

  2. +++ b/commerce_node_checkout.install
    @@ -171,5 +194,29 @@ function _commerce_node_checkout_installed_instances() {
    +// This update hook allows addition of sticky/promote feature by simply updating
    +//  the module
    

    Needs to be on one line and start with 'Adds' for user to see it in the UI.

    Also, needs to be a docblock and not an inline comment.

  3. +++ b/commerce_node_checkout.install
    @@ -171,5 +194,29 @@ function _commerce_node_checkout_installed_instances() {
    +function _commerce_node_checkout_sticky_promote() {
    

    Needs a docblock.

  4. +++ b/commerce_node_checkout.module
    @@ -4,6 +4,9 @@
    +define('STICKY', 'Sticky');
    +define('PROMOTE', 'Promote');
    

    Constants need to start with the module name and be upper-case.

    e.g. COMMERCE_NODE_CHECKOUT_STICKY

  5. +++ b/commerce_node_checkout.module
    @@ -148,6 +157,29 @@ function commerce_node_checkout_process_element($element) {
    +      $desc = t('Enhance your listing by making it sticky at top of lists.');
    ...
    +      $desc = t('Enhance your listing by promoting it to the front page.');
    ...
    +    if (count($ct_option) > 1) $desc = t('Enhance your listing by making it sticky at top of lists, and/or promoting it to the front page.');
    

    Should these strings be configurable on the content-type, as this text might not suit everyone?

  6. +++ b/commerce_node_checkout.module
    @@ -163,6 +195,10 @@ function commerce_node_checkout_get_node_type_enabled_products($type) {
    +function commerce_node_checkout_sticky_promote($type) {
    

    Needs a docblock

  7. +++ b/commerce_node_checkout.module
    @@ -332,3 +377,56 @@ function commerce_node_checkout_get_order_products($order) {
    +        node_make_sticky_action($line_item_wrapper->commerce_node_checkout_node->value());
    ...
    +        node_promote_action($line_item_wrapper->commerce_node_checkout_node->value());
    

    I still don't understand why this is done in a hook and not by our module when we handle publishing?

Also needs a test to ensure we don't get future breakage.

See http://cgit.drupalcode.org/commerce_node_checkout/tree/commerce_node_che... for existing test

thecramp’s picture

hi,
last year i bought the MS script from money script, but there is absolutely no more answer and my licence doesn't work anymore and i need as a lot of us to find a solution to upgrade / downgrade my package... plan ...

i tried the patch, it works i have the promote and sticky in my product .

How can we make those option expire and deactivated after a while ?
Or maybe just upgrade our product by adding this option ( ex: for only 1 month)

Thanks kid regards.

marty.true’s picture

@thecramp: We are using Rules to unpublish nodes after specified times, in combination with the patched module above (my team did the patch). If you are asking if the sticky.promoted elements can be removed from the node but not unpublish the node itself, after some time, this might also be possible with Rules but I haven't tried that... Hope this helps.