本文整理汇总了PHP中comquick2cartHelper::AddUserFieldDetail方法的典型用法代码示例。如果您正苦于以下问题:PHP comquick2cartHelper::AddUserFieldDetail方法的具体用法?PHP comquick2cartHelper::AddUserFieldDetail怎么用?PHP comquick2cartHelper::AddUserFieldDetail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类comquick2cartHelper
的用法示例。
在下文中一共展示了comquick2cartHelper::AddUserFieldDetail方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_cart_item
/**
* Function: updatecart updates the cart and also calculates the tax and shipping charges
*
* @return json
*
* @since 1.0.0
*/
public function update_cart_item()
{
$comquick2cartHelper = new comquick2cartHelper();
$input = JFactory::getApplication()->input;
$post = $input->post;
$data = $post->get('formData', '', 'STRING');
$cart_item_id = $post->get('cart_item_id', '', 'INT');
$item_id = $post->get('item_id', '', 'INT');
// Get parsed form data
parse_str($post->get('formData', '', 'STRING'), $formData);
// Load cart model
/*$item = Array
(
[id] => 17
[parent] => com_quick2cart
[item_id] => 8 if item_id present then no need of id and parent fields
[count] => 1
[options] => 24,23,22,19
)
<pre>$userdata = Array
(
[23] => Array
(
[itemattributeoption_id] => 23
[type] => Textbox
[value] => qqq
)
[24] => Array
(
[itemattributeoption_id] => 24
[type] => Textbox
[value] => www
)
)
* */
$itemFromattedDet = array();
$itemFromattedDet['item_id'] = $item_id;
$userdata = array();
if (!empty($formData['cartDetail']) && !empty($cart_item_id)) {
$newItemDetails = $formData['cartDetail'][$cart_item_id];
$itemFromattedDet['count'] = $newItemDetails['cart_count'];
$itemFromattedDet['options'] = '';
// If not empty attribute details
if (!empty($newItemDetails['attrDetail'])) {
$attrDetail = $newItemDetails['attrDetail'];
foreach ($attrDetail as $key => $attr) {
if ($attr['type'] == 'Textbox' && !empty($attr['value'])) {
$userkey = $attr['itemattributeoption_id'];
$userdata[$userkey] = $attr;
$itemFromattedDet['options'] .= $attr['itemattributeoption_id'] . ',';
} else {
$itemFromattedDet['options'] .= $attr['value'] . ',';
}
}
}
}
$path = JPATH_SITE . "/components/com_quick2cart/models/cart.php";
$comquick2cartHelper->loadqtcClass($path, 'Quick2cartModelcart');
$Quick2cartModelcart = new Quick2cartModelcart();
// Remove last comma
if (!empty($itemFromattedDet['options'])) {
$tempArray = explode(',', $itemFromattedDet['options']);
$tempArray = array_filter($tempArray, "strlen");
$itemFromattedDet['options'] = implode(',', $tempArray);
}
// Get formated product details (internal)
$prod_details = $Quick2cartModelcart->getProd($itemFromattedDet);
// If option present
if (!empty($prod_details[1])) {
// Add user field detail to options
$AttrOptions = $prod_details[1];
$prod_details[1] = $comquick2cartHelper->AddUserFieldDetail($AttrOptions, $userdata);
}
// Update the cart
$result = $Quick2cartModelcart->putCartitem('', $prod_details, $cart_item_id);
// Validate Result. If added successfully.
if (is_numeric($result) && $result == 1) {
$msg['status'] = true;
$msg['successCode'] = 1;
//$msg['message'] = JText::sprintf('COM_QUICK2CART_COMPACT_MSG', $prod_details[0]['name'], $item_count);
} else {
$msg['status'] = false;
$msg['successCode'] = 0;
$msg['message'] = $result;
}
echo json_encode($msg);
jexit();
}