You are here:  » Insert function


Insert function

Submitted by smithdp1 on Mon, 2014-02-17 23:23 in

Hey David I am trying to create a cart on my site and I am doing some custom programming. I was wondering if there is a global insert function in PT that I could use.

Thanks.
DSmith

Submitted by support on Tue, 2014-02-18 08:20

Hi DSmith,

The main insert function is admin__importRecordHandler() in includes/admin.php which handles each record of a feed as it is processed by the parser. Strictly speaking there is no reason why it cannot be called via a simple wrapper that also sets the relevant global variables, for example something like:

<?php
  
function insert_product($merchant,$name,$description,$image_url,$buy_url,$price,$category,$brand)
  {
    global 
$admin_importFeed;
    
$admin_importFeed = array(
        
"field_merchant" => "merchant",
        
"field_name" => "name",
        
"field_description" => "description",
        
"field_image_url" => "image_url",
        
"field_buy_url" => "buy_url",
        
"field_price" => "price",
        
"field_category" => "category",
        
"field_brand" => "brand"
      
)
    
$record = array(
        
"merchant" => $merchant,
        
"name" => $name,
        
"description" => $description,
        
"image_url" => $image_url,
        
"buy_url" => $buy_url,
        
"price" => $price,
        
"category" => $category,
        
"brand" => $brand
      
)
    
admin__importRecordHandler($record);
  }
?>

That may be the sort of thing you're after, bear in mind that "cart" details are typically per customer and would be maintained in their own right - I was wondering if you might have been after something along the lines of the shortlist feature described in this thread...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com