Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ($validate_decreasing) {
- $query = new EntityFieldQuery();
- $query->entityCondition('entity_type', 'commerce_auction_bid')
- // ->entityCondition('bundle', 'reverse_auction_bid')
- ->entityCondition('bundle', 'auction_bid')
- ->fieldCondition('reverse_auction_ref', 'target_id', $form_state['#node']->nid, '=')
- ->propertyOrderBy('changed', 'DESC')->range(0, 1);
- $result = $query->execute();
- if ($result) {
- $entity_id = array_shift($result['commerce_auction_bid']);
- $entity = entity_load('commerce_auction_bid', array($entity_id->id));
- $entity = $entity[$entity_id->id];
- $bid_amount_field = field_get_items('commerce_auction_bid', $entity, 'bid_amount');
- if ($bid_amount_field) {
- if ($bid_amount_field[0]['amount'] <= $bid_amount) {
- $amount = commerce_currency_amount_to_decimal($bid_amount_field[0]['amount'], commerce_default_currency());
- $currency = commerce_currency_load(commerce_default_currency());
- // 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)));
- // form_set_error('bid_amount', t('Your bid amount should be less than previous bid (@pre).', array('@pre' => $currency['symbol'] . $amount)));
- drupal_set_message(t('Your bid amount should be less than previous bid (@pre).', array('@pre' => $currency['symbol'] . $amount)), 'error');
- }
- }
- // $product_field = field_get_items('commerce_auction_bid', $entity, 'field_product');
- // if ($product_field) {
- // $product = commerce_product_load($product_field[0]['product_id']);
- // $price = field_get_items('commerce_product', $product, 'commerce_price');
- // if ($price) {
- // if ($price[0]['amount'] <= $bid_amount) {
- // $amount = commerce_currency_amount_to_decimal($max_amount[0]['amount'], commerce_default_currency());
- // $currency = commerce_currency_load(commerce_default_currency());
- // 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)));
- // }
- // }
- // }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement