Beispiel #1
0
/**
 * shopp_rmv_order_line_data - remove all or one data key=>value pair from the order line data array
 *
 * @api
 * @since 1.2
 *
 * @param int $order (required) the order id
 * @param int $line (required) the order line item
 * @param string $name (optional default:false) the key to remove, removes all data when false
 * @return bool true on success, false on failure
 **/
function shopp_rmv_order_line_data($order = false, $line = 0, $name = false)
{
    $Lines = shopp_order_lines($order);
    if (empty($Lines) || $line >= count($Lines) || !isset($Lines[$line])) {
        return false;
    }
    $Purchased = new ShoppPurchased();
    $Purchased->populate($Lines[$line]);
    if (!is_array($Purchased->data)) {
        $Purchased->data = array();
    }
    if ($name && in_array($name, array_keys($Purchased->data))) {
        unset($Purchased->data[$name]);
    }
    $Purchased->save();
}
Beispiel #2
0
 /**
  * Builds purchased records from cart items attached to the given Purchase ID
  *
  * @author Jonathan Davis
  * @since 1.2.2
  *
  * @param int $purchaseid The Purchase id to attach the purchased records to
  * @return void
  **/
 public function items($purchaseid)
 {
     foreach ($this->Cart as $Item) {
         // Build purchased records from cart items
         $Purchased = new ShoppPurchased();
         $Purchased->purchase = $purchaseid;
         $Purchased->copydata($Item);
         $Purchased->save();
     }
     $this->checksum = $this->Cart->checksum;
     // Track the cart contents checksum to detect changes.
 }