1

I need to set Sticky enable automatically once the customer completes the ubercart order.

I have tried this by creating custom module but didn't work. Here is my code :

function mymodule_purchasePaidListing($order){

  $i=0;
  foreach ($order->products as $key => $value) {
    if ($i>=1){
      break;
    }

    if ($i==0){

    $product_node_id = reset($value->data['attributes']['Product Node ID']); 

      if ($product_node_id){
        $node = node_load($product_node_id);

        $node->sticky=1;

        node_save($node);
      }

    } 
  $i++;
  }

}

Note : I am getting Node id in Product attribute Product Node ID mentioned above.

Any Help?

8
  • Most likely the $product_node_id does not exist. – mchar Feb 23 '17 at 7:37
  • $product_node_id is exist. Can you please let me know how do I print the $order variable ? also let me know how to check whether above function is working or not. – mysti Feb 23 '17 at 8:24
  • Use kprint_r($order) or kpr($order) if you have drush installed, otherwise use print '<pre>'; var_dump print '</pre>';, but I can't tell if your function functions or not. From a quick search that I did I found no results for hook_purchasePaidListing... – mchar Feb 23 '17 at 8:38
  • Is there any other way to set Sticky enable automatically once the customer completes the ubercart order? – mysti Feb 23 '17 at 8:42
  • I tried this var_dump($order); But it returns NULL value. Why? – mysti Feb 23 '17 at 8:55

Your Answer

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

Browse other questions tagged or ask your own question.