[gelöst]$order->uid auslesen
am 09.09.2010 - 18:45 Uhr in
Hallo,
ich habe eine Funktion geschrieben, die es ermöglicht bei Bestellungen aus Ubercart Rollen automatisch Userbezogen zu limitieren, d.h. die Anzahl an zulässigen Posts eines bestimmten Contenttyps:
Hat sich schon erledigt. Ich habe die Funktion in uc-roles.ca.inc in einer foreach products as $product funktion eingebunden. Falls es jemanden interesstiert:
Die Variable $nid1 einfach durch die nid des jeweiligen Contenttypes ersetzen. Dann für die Variable $type jeweils die maschinenlesbare Bezeichnung des Contenttypes einfügen und schon kann man Benutzern automatisch bei Bestellungen die jeweilige Anzahl an gebuchten Anzeigen selbstständig ausführen lassen: Funktion wird ausgeführt sobald man eine Bestellung auch "abgeschlossen" setzt.
Es sind noch kleine Anpassungen in der Datenbank dafür nötig. module ubercart, node limit
<?php
/**
* set node limit
*
* @function
*/
$orderid=$order->order_id;
$userid= $order->uid;
$nid1=$product->nid;
if($nid1=="23")
{
$type="stellenangebot_basic";
$title=$order->uid;
$lim=$product->qty;
$limit=1*$lim;
$weight=0;
$sql = "SELECT * FROM {node_limit} WHERE uid = %d and type='%s'";
$result = db_query($sql, $userid, $type);
$row = db_fetch_object($result);
$orderidalt = $row->orderid;
$limitalt = $row->limit;
if($orderidalt==""){
db_query("INSERT INTO {node_limit_user} VALUES('%d', '%d')", $lid, $userid);
db_query("INSERT INTO {node_limit} VALUES('%d', '%s', '%d', '%s', '%d','%d','%d')", $lid, $type, $limit, $title, $weight, $orderid, $userid);
}
elseif($orderidalt=="$orderid")
{
$type="stellenangebot_basic";
$title=$order->uid;
$lim=$product->qty;
$limit=1*$lim;
$weight=0;
db_query("UPDATE {node_limit} SET `limit` = '%s', orderid =%d where uid = %d and type ='%s'", $limit, $orderid, $userid, $type);
}
elseif($orderidalt!="$orderid")
{
$type="stellenangebot_basic";
$title=$order->uid;
$lim=$product->qty;
$limit=1*$lim + $limitalt;
$weight=0;
db_query("UPDATE {node_limit} SET `limit` = '%s', orderid =%d where uid = %d and type ='%s'", $limit, $orderid, $userid, $type);
}
}
if($nid1=="26")
{
$type="stellenangebot_premium";
$title=$order->uid;
$lim=$product->qty;
$limit=1*$lim;
$weight=0;
$sql = "SELECT * FROM {node_limit} WHERE uid = %d and type='%s'";
$result = db_query($sql, $userid, $type);
$row = db_fetch_object($result);
$orderidalt = $row->orderid;
$limitalt = $row->limit;
if($orderidalt==""){
db_query("INSERT INTO {node_limit_user} VALUES('%d', '%d')", $lid, $userid);
db_query("INSERT INTO {node_limit} VALUES('%d', '%s', '%d', '%s', '%d','%d','%d')", $lid, $type, $limit, $title, $weight, $orderid, $userid);
}
elseif($orderidalt=="$orderid")
{
$type="stellenangebot_premium";
$title=$order->uid;
$lim=$product->qty;
$limit=1*$lim;
$weight=0;
db_query("UPDATE {node_limit} SET `limit` = '%s', orderid =%d where uid = %d and type ='%s'", $limit, $orderid, $userid, $type);
}
elseif($orderidalt!="$orderid")
{
$type="stellenangebot_premium";
$title=$order->uid;
$lim=$product->qty;
$limit=1*$lim + $limitalt;
$weight=0;
db_query("UPDATE {node_limit} SET `limit` = '%s', orderid =%d where uid = %d and type ='%s'", $limit, $orderid, $userid, $type);
}
}
if($nid1=="28")
{
$type="3x_stellenangebot_basic";
$title=$order->uid;
$weight=0;
$lim=$product->qty;
$limit=3*$lim;
$sql = "SELECT * FROM {node_limit} WHERE uid = %d and type='%s'";
$result = db_query($sql, $userid, $type);
$row = db_fetch_object($result);
$orderidalt = $row->orderid;
$limitalt = $row->limit;
if($orderidalt==""){
db_query("INSERT INTO {node_limit_user} VALUES('%d', '%d')", $lid, $userid);
db_query("INSERT INTO {node_limit} VALUES('%d', '%s', '%d', '%s', '%d','%d','%d')", $lid, $type, $limit, $title, $weight, $orderid, $userid);
}
elseif($orderidalt=="$orderid")
{
$type="3x_stellenangebot_basic";
$title=$order->uid;
$weight=0;
$lim=$product->qty;
$limit=3*$lim;
db_query("UPDATE {node_limit} SET `limit` = '%s', orderid =%d where uid = %d and type ='%s'", $limit, $orderid, $userid, $type);
}
elseif($orderidalt!="$orderid")
{
$type="3x_stellenangebot_basic";
$title=$order->uid;
$weight=0;
$lim=$product->qty;
$limit=3*$lim;
db_query("UPDATE {node_limit} SET `limit` = '%s', orderid =%d where uid = %d and type ='%s'", $limit, $orderid, $userid, $type);
}
}
if($nid1=="29")
{
$type="3x_stellenangebot_premium";
$title=$order->uid;
$weight=0;
$lim=$product->qty;
$limit=3*$lim;
$sql = "SELECT * FROM {node_limit} WHERE uid = %d and type='%s'";
$result = db_query($sql, $userid, $type);
$row = db_fetch_object($result);
$orderidalt = $row->orderid;
$limitalt = $row->limit;
if($orderidalt==""){
db_query("INSERT INTO {node_limit_user} VALUES('%d', '%d')", $lid, $userid);
db_query("INSERT INTO {node_limit} VALUES('%d', '%s', '%d', '%s', '%d','%d','%d')", $lid, $type, $limit, $title, $weight, $orderid, $userid);
}
elseif($orderidalt=="$orderid")
{
$type="3x_stellenangebot_premium";
$title=$order->uid;
$weight=0;
$lim=$product->qty;
$limit=3*$lim;
db_query("UPDATE {node_limit} SET `limit` = '%s', orderid =%d where uid = %d and type ='%s'", $limit, $orderid, $userid, $type);
}
elseif($orderidalt!="$orderid")
{
$type="3x_stellenangebot_premium";
$title=$order->uid;
$weight=0;
$lim=$product->qty;
$limit=3*$lim;
db_query("UPDATE {node_limit} SET `limit` = '%s', orderid =%d where uid = %d and type ='%s'", $limit, $orderid, $userid, $type);
}
}
if($nid1=="30")
{
$type="enterprise_basic";
$title=$order->uid;
$weight=0;
$lim=$product->qty;
$limit=10*$lim;
$sql = "SELECT * FROM {node_limit} WHERE uid = %d and type='%s'";
$result = db_query($sql, $userid, $type);
$row = db_fetch_object($result);
$orderidalt = $row->orderid;
$limitalt = $row->limit;
if($orderidalt==""){
db_query("INSERT INTO {node_limit_user} VALUES('%d', '%d')", $lid, $userid);
db_query("INSERT INTO {node_limit} VALUES('%d', '%s', '%d', '%s', '%d','%d','%d')", $lid, $type, $limit, $title, $weight, $orderid, $userid);
}
elseif($orderidalt=="$orderid")
{
$type="enterprise_basic";
$title=$order->uid;
$weight=0;
$lim=$product->qty;
$limit=10*$lim;
db_query("UPDATE {node_limit} SET `limit` = '%s', orderid =%d where uid = %d and type ='%s'", $limit, $orderid, $userid, $type);
}
elseif($orderidalt!="$orderid")
{
$type="enterprise_basic";
$title=$order->uid;
$weight=0;
$lim=$product->qty;
$limit=10*$lim;
db_query("UPDATE {node_limit} SET `limit` = '%s', orderid =%d where uid = %d and type ='%s'", $limit, $orderid, $userid, $type);
}
}
if($nid1=="31")
{
$type="enterprise_premium";
$title=$order->uid;
$weight=0;
$lim=$product->qty;
$limit=10*$lim;
$sql = "SELECT * FROM {node_limit} WHERE uid = %d and type='%s'";
$result = db_query($sql, $userid, $type);
$row = db_fetch_object($result);
$orderidalt = $row->orderid;
$limitalt = $row->limit;
if($orderidalt==""){
db_query("INSERT INTO {node_limit_user} VALUES('%d', '%d')", $lid, $userid);
db_query("INSERT INTO {node_limit} VALUES('%d', '%s', '%d', '%s', '%d','%d','%d')", $lid, $type, $limit, $title, $weight, $orderid, $userid);
}
elseif($orderidalt=="$orderid")
{
$type="enterprise_premium";
$title=$order->uid;
$weight=0;
$lim=$product->qty;
$limit=10*$lim;
db_query("UPDATE {node_limit} SET `limit` = '%s', orderid =%d where uid = %d and type ='%s'", $limit, $orderid, $userid, $type);
}
elseif($orderidalt!="$orderid")
{
$type="enterprise_premium";
$title=$order->uid;
$weight=0;
$lim=$product->qty;
$limit=10*$lim;
db_query("UPDATE {node_limit} SET `limit` = '%s', orderid =%d where uid = %d and type ='%s'", $limit, $orderid, $userid, $type);
}
}
?>
- Anmelden oder Registrieren um Kommentare zu schreiben
Neue Kommentare
vor 2 Tagen 5 Stunden
vor 3 Tagen 1 Stunde
vor 3 Tagen 3 Stunden
vor 3 Tagen 7 Stunden
vor 3 Tagen 20 Stunden
vor 3 Tagen 21 Stunden
vor 4 Tagen 7 Stunden
vor 4 Tagen 20 Stunden
vor 4 Tagen 22 Stunden
vor 4 Tagen 22 Stunden