Back to PhocacartShipping class

Method storeShippingRegistered

public
storeShippingRegistered
(mixed $shippingId, mixed $userId)
Store shipping id inside checkout - if enabled in parameters and there is only one valid shipping, it can be directly stored But then the cart needs to be reloaded to store the costs of the shipping and make ready for payment (payment gets info about shipping because of rules)
Parameters
  • $shippingId
  • $userId

Method storeShippingRegistered - Source code

/**
 * Store shipping id inside checkout - if enabled in parameters and there is only one valid shipping, it can be directly stored
 * But then the cart needs to be reloaded to store the costs of the shipping and make ready for payment (payment gets info about shipping because of rules)
 * @param $shippingId
 * @param $userId
 */
public function storeShippingRegistered($shippingId, $userId)
{
    $row = Table::getInstance('PhocacartCart', 'Table');
    if ((int) $userId > 0) {
        if (!$row->load(array('user_id' => (int) $userId, 'vendor_id' => 0, 'ticket_id' => 0, 'unit_id' => 0, 'section_id' => 0))) {
            return false;
            // there must be some info in cart yet
        }
    }
    if (!empty($row->cart)) {
        $data['shipping'] = (int) $shippingId;
        $data['user_id'] = (int) $userId;
        if (!$row->bind($data)) {
            $this->setError($row->getError());
            return false;
        }
        $row->date = gmdate('Y-m-d H:i:s');
        if (!$row->check()) {
            $this->setError($row->getError());
            return false;
        }
        if (!$row->store()) {
            $this->setError($row->getError());
            return false;
        }
        return (int) $shippingId;
    }
    return false;
}