Advertisement
polosatique

Untitled

Sep 29th, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.24 KB | None | 0 0
  1. if ($validate_decreasing) {
  2.   $query = new EntityFieldQuery();
  3.   $query->entityCondition('entity_type', 'commerce_auction_bid')
  4. //          ->entityCondition('bundle', 'reverse_auction_bid')
  5.     ->entityCondition('bundle', 'auction_bid')
  6.     ->fieldCondition('reverse_auction_ref', 'target_id', $form_state['#node']->nid, '=')
  7.     ->propertyOrderBy('changed', 'DESC')->range(0, 1);
  8.   $result = $query->execute();
  9.   if ($result) {
  10.     $entity_id = array_shift($result['commerce_auction_bid']);
  11.     $entity = entity_load('commerce_auction_bid', array($entity_id->id));
  12.     $entity = $entity[$entity_id->id];
  13.  
  14.     $bid_amount_field = field_get_items('commerce_auction_bid', $entity, 'bid_amount');
  15.  
  16.     if ($bid_amount_field) {
  17.       if ($bid_amount_field[0]['amount'] <= $bid_amount) {
  18.         $amount = commerce_currency_amount_to_decimal($bid_amount_field[0]['amount'], commerce_default_currency());
  19.         $currency = commerce_currency_load(commerce_default_currency());
  20. //          form_set_error('bid_product][und][form][product_details', t('Your bid amount should be less than previous bid (@pre).', array('@pre' => $currency['symbol'] . $amount)));
  21. //          form_set_error('bid_amount', t('Your bid amount should be less than previous bid (@pre).', array('@pre' => $currency['symbol'] . $amount)));
  22.         drupal_set_message(t('Your bid amount should be less than previous bid (@pre).', array('@pre' => $currency['symbol'] . $amount)), 'error');
  23.       }
  24.     }
  25.  
  26. //      $product_field = field_get_items('commerce_auction_bid', $entity, 'field_product');
  27. //      if ($product_field) {
  28. //        $product = commerce_product_load($product_field[0]['product_id']);
  29. //        $price = field_get_items('commerce_product', $product, 'commerce_price');
  30. //        if ($price) {
  31. //          if ($price[0]['amount'] <= $bid_amount) {
  32. //            $amount = commerce_currency_amount_to_decimal($max_amount[0]['amount'], commerce_default_currency());
  33. //            $currency = commerce_currency_load(commerce_default_currency());
  34. //            form_set_error('bid_product][und][form][product_details', t('Your bid amount should be less than previous bid (@pre).', array('@pre' => $currency['symbol'] . $amount)));
  35. //          }
  36. //        }
  37. //      }
  38.   }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement