本文整理汇总了PHP中ProductCategory::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductCategory::delete方法的具体用法?PHP ProductCategory::delete怎么用?PHP ProductCategory::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProductCategory
的用法示例。
在下文中一共展示了ProductCategory::delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteCategory
public function deleteCategory($id)
{
$db = $this->db;
$deleted = new ProductCategory();
$deleted->delete($db, $id);
}
示例2: workflow
/**
* Handles loading, saving and deleting categories in a workflow context
*
* @author Jonathan Davis
* @since 1.0
* @return void
**/
public function workflow()
{
$defaults = array('action' => false, 'selected' => array(), 'page' => false, 'id' => false, 'save' => false, 'next' => false, '_wpnonce' => false);
$args = array_merge($defaults, $_REQUEST);
extract($args, EXTR_SKIP);
if (!defined('WP_ADMIN') || $page != $this->page()) {
return false;
}
$adminurl = admin_url('admin.php');
add_screen_option('per_page', array('label' => __('Categories Per Page', 'Shopp'), 'default' => 20, 'option' => 'edit_' . ProductCategory::$taxon . '_per_page'));
if ('delete' == $action && wp_verify_nonce($_wpnonce, 'shopp_categories_manager')) {
if (!empty($id)) {
$selected = array($id);
}
$total = count($selected);
foreach ($selected as $selection) {
$DeletedCategory = new ProductCategory($selection);
$deleted = $DeletedCategory->name;
$DeletedCategory->delete();
}
if (1 == $total) {
$this->notice(Shopp::__('Deleted %s category.', "<strong>{$deleted}</strong>"));
} else {
$this->notice(Shopp::__('Deleted %s categories.', "<strong>{$total}</strong>"));
}
$reset = array('selected' => null, 'action' => null, 'id' => null, '_wpnonce' => null);
$redirect = add_query_arg(array_merge($_GET, $reset), $adminurl);
Shopp::redirect($redirect);
exit;
}
if ($id && 'new' != $id) {
$Category = new ProductCategory($id);
} else {
$Category = new ProductCategory();
}
$meta = array('specs', 'priceranges', 'options', 'prices');
foreach ($meta as $prop) {
if (!isset($Category->{$prop})) {
$Category->{$prop} = array();
}
}
if ($save) {
$this->save($Category);
// Workflow handler
if (isset($_REQUEST['settings']) && isset($_REQUEST['settings']['workflow'])) {
$workflow = $_REQUEST['settings']['workflow'];
$working = array_search($id, $this->worklist);
switch ($workflow) {
case 'close':
$next = 'close';
break;
case 'new':
$next = 'new';
break;
case 'next':
$key = $working + 1;
break;
case 'previous':
$key = $working - 1;
break;
}
if (isset($key)) {
$next = isset($this->worklist[$key]) ? $this->worklist[$key] : 'close';
}
}
if ($next) {
if ('new' == $next) {
$Category = new ProductCategory();
} else {
$Category = new ProductCategory($next);
}
} else {
if (empty($id)) {
$id = $Category->id;
}
$Category = new ProductCategory($id);
}
}
ShoppCollection($Category);
}
示例3: shopp_rmv_product_category
/**
* Remove a product category by id
*
* @api
* @since 1.2
*
* @param int $id (required) The category id
* @return bool true on success, false on failure
**/
function shopp_rmv_product_category($id = false)
{
if (!$id) {
shopp_debug(__FUNCTION__ . " failed: Category id required.");
return false;
}
$Category = new ProductCategory($id);
if (empty($Category->id)) {
return false;
}
return $Category->delete();
}