function fetch($cols = '', $kids = false, $get_images = false) { $info = parent::fetch($cols, $kids); if ($get_images) { $info['images'] = $this->get_images(null, $get_images); } return $info; }
function fetch_any($cols = null, $offset = 0, $range = 0, $orderby = null, $where = '', $orderdir = 'ASC') { if (!empty($where)) { $where .= " AND"; } $where .= " cm_products_id = " . $this->db->quote($this->_cm_product_id); if (!$orderby) { $orderby = 'order_weight,optkey'; } return parent::fetch_any($cols, $offset, $range, $orderby, $where, $orderdir); }
/** * store form values. Special post-save proc for sending notifications. */ function store($vals) { $res = parent::store($vals); if (!PEAR::isError($res) or $res->getCode() == DBCON_ZERO_EFFECT) { if (!empty($vals['do_notify']) && !empty($vals['belongs_email'])) { $this->send_coupon_notification($vals['belongs_email'], $vals['belongs_name']); } } return $res; }
/** * extend parent to clear our little cache */ function set_id($id) { $this->_catpath_cache = null; parent::set_id($id); }
/** * store a new basis for the given method * @param $meth_id int the ship_method id * @param $min int minimum of the range * @param $max int max of the range * @param $cost int how much it will cost ya * @throws PE */ function store_basis($methid, $min, $max, $cost) { global $pdb; $dbc = new db_container($pdb); $dbc->set_table('cm_shipmethods_zone_costs'); $vals = array('cm_shipmethods_zone_methods_id' => $methid, 'basis_min' => $min, 'basis_max' => $max, 'cost' => $cost); return $dbc->store($vals, true); }
} elseif ($ACTION == OP_GC_LOAD && defined('CSHOP_CONTROL_SHOW_STS_GIFTCARD_LOADER') && CSHOP_CONTROL_SHOW_STS_GIFTCARD_LOADER) { $order->set_id_by_token($itemid); $gc = cmClassFactory::getInstanceOf(CSHOP_CLASSES_GIFTCARD, $pdb); $gc->setErrorHandling(PEAR_ERROR_RETURN); $orderitems = $order->fetch_items(); $errs = array(); foreach ($orderitems as $item) { if (in_array($item['id'], array_keys($_POST['gc_number']))) { $successful_cards = array(); $gc_numbers = $_POST['gc_number'][$item['id']]; # get product's STS merchant ID $product = cmClassFactory::getInstanceOf(CSHOP_CLASSES_PRODUCT, $pdb); $product->set_id($item['product_id']); $product_merch_id = $product->get_header('sts_merchant_id'); # store the giftcard details as options on the order line item, so admin can see $oi = db_container::factory($pdb, $order->_items_table); $oi->set_id($item['id']); for ($i = 0; $i < count($gc_numbers); $i++) { $gc_number = trim($gc_numbers[$i]); if (!empty($gc_number)) { if (empty($product_merch_id)) { $errs[] = "Product \"{$item['product_descrip']}\" does not have a STS Merchant ID, so can\\'t be activated here."; } elseif ($gc->find_by_card_number($gc_number)) { $errs[] = "Card Number \"{$gc_number}\" is already in the system, and cannot be activated again."; } else { $res = $gc->activate($order, $product_merch_id, $item['price'], $gc_number); # TESTING $res = print_r(array($product_merch_id, $item['price'], $gc_number)); if (!PEAR::isError($res)) { $successful_cards[] = $gc->fetch(array('gc_no', 'transaction_id')); # TESTING $successful_cards[] = array('gc_no'=>rand('100000000000001','999999999999999'), 'transaction_id' => '3e12982132131038oi'); } else {
/** * does the order contains any digital items. * @return bool */ function fetch_digital_goods() { if (!defined('CSHOP_ENABLE_DIGITAL_DOWNLOADS') || !CSHOP_ENABLE_DIGITAL_DOWNLOADS) { return; } if (defined('CSHOP_DOWNLOAD_LINK_FMT')) { $sql = sprintf("SELECT id, product_id, product_descrip, download_token FROM %s WHERE is_digital = 1 AND order_id = %d", $this->_items_table, $this->get_id()); $res = $this->db->query($sql); $items = array(); while ($row = $res->fetchRow()) { if (empty($row['download_token'])) { // create and save new URL if not done yet. $row['download_token'] = $this->generate_download_token($row['product_id']); $oi = db_container::factory($this->db, $this->_items_table); $oi->set_id($row['id']); $oi->store(array('download_token' => $row['download_token'])); } $row['download_url'] = sprintf(CSHOP_DOWNLOAD_LINK_FMT, $this->fetch_token(), $row['download_token']); $items[] = $row; } return $items; } }