Skip to main content
added 150 characters in body
Source Link
CR47
  • 1.1k
  • 13
  • 35
function commerce_giftcards_action_change_qty_one($current_order, $current_line_item) {
  dpm('Current Order ID: ' . $current_order->order_number);
  dpm('Updated Line Item ID: ' . $current_line_item->line_item_id);
  dpm('Updated Line Item Type: ' . $current_line_item->type);

  db_update('commerce_line_item')
    ->fields(array('quantity' => '1.00'))
    ->condition('type''line_item_id', $current_line_item->line_item_id, '=')
    ->execute();

}

The correct fields are printing in the messages but the database is not updating unless I am going back to the product's page and adding another to the cart. Nothing in It only keeps the logs says there is an issue eitherquantity at 1 if I hit add to cart more than once.

EDIT 3: Running If I change the db_updatequantity of the item on the cart page it still increases the quantity in devel/php did not update the database either, so therewhile also displaying the message that says only 1 qty of that item is something wrong with my db_update queryallowed.

function commerce_giftcards_action_change_qty_one($current_order, $current_line_item) {
  dpm('Current Order ID: ' . $current_order->order_number);
  dpm('Updated Line Item ID: ' . $current_line_item->line_item_id);
  dpm('Updated Line Item Type: ' . $current_line_item->type);

  db_update('commerce_line_item')
    ->fields(array('quantity' => '1.00'))
    ->condition('type', $current_line_item->line_item_id, '=')
    ->execute();

}

The correct fields are printing in the messages but the database is not updating. Nothing in the logs says there is an issue either.

EDIT 3: Running the db_update in devel/php did not update the database either, so there is something wrong with my db_update query.

function commerce_giftcards_action_change_qty_one($current_order, $current_line_item) {
  dpm('Current Order ID: ' . $current_order->order_number);
  dpm('Updated Line Item ID: ' . $current_line_item->line_item_id);
  dpm('Updated Line Item Type: ' . $current_line_item->type);

  db_update('commerce_line_item')
    ->fields(array('quantity' => '1.00'))
    ->condition('line_item_id', $current_line_item->line_item_id, '=')
    ->execute();

}

The correct fields are printing in the messages but the database is not updating unless I am going back to the product's page and adding another to the cart. It only keeps the quantity at 1 if I hit add to cart more than once. If I change the quantity of the item on the cart page it still increases the quantity in the database while also displaying the message that says only 1 qty of that item is allowed.

added 135 characters in body; edited tags
Source Link
CR47
  • 1.1k
  • 13
  • 35

EDIT 3: Running the db_update in devel/php did not update the database either, so there is something wrong with my db_update query.

EDIT 3: Running the db_update in devel/php did not update the database either, so there is something wrong with my db_update query.

added 773 characters in body
Source Link
CR47
  • 1.1k
  • 13
  • 35

EDIT 2: I created a custom rules action to manually update the quantity in the commerce_line_item table which also does not seem to work:

function commerce_giftcards_action_change_qty_one($current_order, $current_line_item) {
  dpm('Current Order ID: ' . $current_order->order_number);
  dpm('Updated Line Item ID: ' . $current_line_item->line_item_id);
  dpm('Updated Line Item Type: ' . $current_line_item->type);

  db_update('commerce_line_item')
    ->fields(array('quantity' => '1.00'))
    ->condition('type', $current_line_item->line_item_id, '=')
    ->execute();

}

The correct fields are printing in the messages but the database is not updating. Nothing in the logs says there is an issue either.

EDIT 2: I created a custom rules action to manually update the quantity in the commerce_line_item table which also does not seem to work:

function commerce_giftcards_action_change_qty_one($current_order, $current_line_item) {
  dpm('Current Order ID: ' . $current_order->order_number);
  dpm('Updated Line Item ID: ' . $current_line_item->line_item_id);
  dpm('Updated Line Item Type: ' . $current_line_item->type);

  db_update('commerce_line_item')
    ->fields(array('quantity' => '1.00'))
    ->condition('type', $current_line_item->line_item_id, '=')
    ->execute();

}

The correct fields are printing in the messages but the database is not updating. Nothing in the logs says there is an issue either.

added 154 characters in body
Source Link
CR47
  • 1.1k
  • 13
  • 35
Loading
added 140 characters in body
Source Link
CR47
  • 1.1k
  • 13
  • 35
Loading
Source Link
CR47
  • 1.1k
  • 13
  • 35
Loading