cubecart / v6

CubeCart Version 6
https://cubecart.com
71 stars 58 forks source link

Restrict to Selected GC Delivery Method #1396

Closed bhsmither closed 7 years ago

bhsmither commented 7 years ago

In Cart->add(), near line 234, there is:

$this->basket['contents'][$hash] = array(
  'id'   => $product_id,
  'quantity'  => $quantity,
  'digital'  => ($optionsArray['method'] == 'e') ? true : false,
  'certificate' => array(
    'value'   => $optionsArray['value'],
    'name'   => $optionsArray['name'],
    'email'   => $optionsArray['email'],
    'message'  => $optionsArray['message'],
  ),
);

This fails to enter into what will be the 'custom' blob the chosen delivery method. It is true that 'digital' is set to true and gets databased in the 'digital' column of CubeCart_order_inventory, but more can be done.

Suggest:

$this->basket['contents'][$hash] = array(
  'id'   => $product_id,
  'quantity'  => $quantity,
  'digital'  => ($optionsArray['method'] == 'e') ? true : false,
  'certificate' => array( // CubeCart_order_inventory, 'custom' column, serialized
    'value'   => $optionsArray['value'],
    'name'   => $optionsArray['name'],
    'email'   => $optionsArray['email'],
    'message'  => $optionsArray['message'],
    'method' => $optionsArray['method'], // 'e' or 'm'
  ),
);

Then, knowing that Order->_sendCoupon() has this delivery method within $data, we can choose to email the cart.gift_certificate template, or prepare for something else - such as:

Also, have a hook: class.order.send.physical.coupon.

Alternately:

In Order->orderStatus(), case:ORDER_COMPLETE, there is:

// Send Gift Certificate
if (!empty($item['custom']) && !empty($item['coupon_id'])) {
  $this->_sendCoupon($item['coupon_id'], unserialize($item['custom']));
}

If wanting to only email if the GC order inventory item is digital = 1, suggest:

if (!empty($item['custom']) && !empty($item['coupon_id']) && $item['digital']) {
  $this->_sendCoupon($item['coupon_id'], unserialize($item['custom']));
}

See: #1366

abrookbanks commented 7 years ago

Email or Postal Gift Card screen shot 2017-02-03 at 15 52 31