本文整理汇总了PHP中ps_product::is_downloadable方法的典型用法代码示例。如果您正苦于以下问题:PHP ps_product::is_downloadable方法的具体用法?PHP ps_product::is_downloadable怎么用?PHP ps_product::is_downloadable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ps_product
的用法示例。
在下文中一共展示了ps_product::is_downloadable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateRecords
//.........这里部分代码省略.........
$fields = array('order_id' => $order_id, 'user_info_id' => $d["ship_to_info_id"], 'vendor_id' => $vendor_id, 'product_id' => $cart[$i]["product_id"], 'order_item_sku' => $dboi->f("product_sku"), 'order_item_name' => $dboi->f("product_name"), 'product_quantity' => $cart[$i]["quantity"], 'product_item_price' => $product_price, 'product_final_price' => $product_final_price, 'order_item_currency' => $GLOBALS['product_currency'], 'order_status' => 'P', 'product_attribute' => $description, 'cdate' => $timestamp, 'mdate' => $timestamp);
$db->buildQuery('INSERT', '#__{vm}_order_item', $fields);
$db->query();
// Update Stock Level and Product Sales, decrease - no matter if in stock or not!
$q = "UPDATE #__{vm}_product ";
$q .= "SET product_in_stock = product_in_stock - " . (int) $cart[$i]["quantity"];
$q .= " WHERE product_id = '" . $cart[$i]["product_id"] . "'";
$db->query($q);
$q = "UPDATE #__{vm}_product ";
$q .= "SET product_sales= product_sales + " . (int) $cart[$i]["quantity"];
$q .= " WHERE product_id='" . $cart[$i]["product_id"] . "'";
$db->query($q);
// Update stock of parent product, if all child products are sold, thanks Ragnar Brynjulfsson
if ($dboi->f("product_parent_id") != 0) {
$q = "SELECT COUNT(product_id) ";
$q .= "FROM #__{vm}_product ";
$q .= "WHERE product_parent_id = " . $dboi->f("product_parent_id");
$q .= " AND product_in_stock > 0";
$db->query($q);
$db->next_record();
if (!$db->f("COUNT(product_id)")) {
$q = "UPDATE #__{vm}_product ";
$q .= "SET product_in_stock = 0 ";
$q .= "WHERE product_id = " . $dboi->f("product_parent_id") . " LIMIT 1";
$db->query($q);
}
}
}
######## BEGIN DOWNLOAD MOD ###############
if (ENABLE_DOWNLOADS == "1") {
require_once CLASSPATH . 'ps_order.php';
for ($i = 0; $i < $cart["idx"]; $i++) {
// only handle downloadable products here
if (ps_product::is_downloadable($cart[$i]["product_id"])) {
$params = array('product_id' => $cart[$i]["product_id"], 'order_id' => $order_id, 'user_id' => $auth["user_id"]);
ps_order::insert_downloads_for_product($params);
if (@VM_DOWNLOADABLE_PRODUCTS_KEEP_STOCKLEVEL == '1') {
// Update the product stock level back to where it was.
$q = "UPDATE #__{vm}_product ";
$q .= "SET product_in_stock = product_in_stock + " . (int) $cart[$i]["quantity"];
$q .= " WHERE product_id = '" . (int) $cart[$i]["product_id"] . "'";
$db->query($q);
}
}
}
}
################## END DOWNLOAD MOD ###########
// Export the order_id so the checkout complete page can get it
$d["order_id"] = $order_id;
/*
* Let the shipping module know which shipping method
* was selected. This way it can save any information
* it might need later to print a shipping label.
*/
if (is_callable(array($this->_SHIPPING, 'save_rate_info'))) {
$this->_SHIPPING->save_rate_info($d);
}
// Now as everything else has been done, we can update the Order Status
$update_order = false;
if ($order_total == 0.0) {
// code moved out of $_PAYMENT check as no payment will be needed when $order_total=0.0
// If the Order Total is zero, we can confirm the order to automatically enable the download
$d['order_status'] = ENABLE_DOWNLOAD_STATUS;
$update_order = true;
} elseif (isset($_PAYMENT)) {
if ($d['new_order_status'] != 'P') {
示例2: delete_record
/**
* Deletes one Record.
*/
function delete_record($record_id, &$d)
{
global $db;
$record_id = intval($record_id);
if ($this->validate_delete($record_id)) {
$dbu = new ps_db();
// Get the order items and update the stock level
// to the number before the order was placed
$q = "SELECT order_status, product_id, product_quantity FROM #__{vm}_order_item WHERE order_id={$record_id}";
$db->query($q);
require_once CLASSPATH . 'ps_product.php';
// Now update each ordered product
while ($db->next_record()) {
if (in_array($db->f('order_status'), array('P', 'X', 'R'))) {
continue;
}
if (ENABLE_DOWNLOADS == '1' && ps_product::is_downloadable($db->f("product_id")) && VM_DOWNLOADABLE_PRODUCTS_KEEP_STOCKLEVEL == '1') {
$q = "UPDATE #__{vm}_product \n\t\t\t\t\t\t\tSET product_sales=product_sales-" . $db->f("product_quantity") . " \n\t\t\t\t\t\tWHERE product_id=" . $db->f("product_id");
$dbu->query($q);
} else {
$q = "UPDATE #__{vm}_product \n\t\t\t\t\t\tSET product_in_stock=product_in_stock+" . $db->f("product_quantity") . ",\n\t\t\t\t\t\t\tproduct_sales=product_sales-" . $db->f("product_quantity") . " \n\t\t\t\t\t\tWHERE product_id=" . $db->f("product_id");
$dbu->query($q);
}
}
$q = "DELETE from #__{vm}_orders where order_id='{$record_id}'";
$db->query($q);
$q = "DELETE from #__{vm}_order_item where order_id='{$record_id}'";
$db->query($q);
$q = "DELETE from #__{vm}_order_payment where order_id='{$record_id}'";
$db->query($q);
$q = "DELETE from #__{vm}_product_download where order_id='{$record_id}'";
$db->query($q);
$q = "DELETE from #__{vm}_order_history where order_id='{$record_id}'";
$db->query($q);
$q = "DELETE from #__{vm}_order_user_info where order_id='{$record_id}'";
$db->query($q);
$q = "DELETE FROM #__{vm}_shipping_label where order_id={$record_id}";
$db->query($q);
return True;
} else {
return False;
}
}