Jelajahi Sumber

add usage vs qtymin calc

andre 4 tahun lalu
induk
melakukan
2a140447da
1 mengubah file dengan 68 tambahan dan 0 penghapusan
  1. 68 0
      productressources.php

+ 68 - 0
productressources.php

@@ -0,0 +1,68 @@
+<?php
+
+use WHMCS\Application;
+use WHMCS\Config\Setting;
+use WHMCS\Exception\ProgramExit;
+use WHMCS\Product\Product;
+use WHMCS\Session;
+use WHMCS\User\Client;
+use WHMCS\Database\Capsule;
+use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ResourceManager;
+
+require("../init.php");
+
+/*
+*** USAGE SAMPLES ***
+
+<script language="javascript" src="feeds/productsinfo.php?pid=1&get=name"></script>
+
+<script language="javascript" src="feeds/productsinfo.php?pid=1&get=description"></script>
+
+<script language="javascript" src="feeds/productsinfo.php?pid=1&get=price&billingcycle=monthly&currency=1"></script>
+
+<script language="javascript" src="feeds/productsinfo.php?pid=1&get=orderurl&carttpl=web20cart"></script>
+
+*/
+
+$whmcs = App::self();
+$pid = (int) $whmcs->get_req_var('pid');
+$get = $whmcs->get_req_var('get');
+$language = $whmcs->get_req_var('language') ?: null;
+$data = array();
+$name = $description = '';
+
+// Verify user input for pid exists, is greater than 0, and as is a valid id
+if ($pid > 0) {
+    $data = Capsule::table('tblproducts')
+        ->where('id', '=', $pid)
+        ->first();
+    $pid = (int) $data->id;
+    // If there is a user logged in, we will use the client language
+    if (((int) $userId = Session::get('userid'))) {
+        $language = Client::find($userId, array('language'))->language ?: null;
+    }
+    $name = Product::getProductName($pid, $data->name, $language);
+    $description = Product::getProductDescription($pid, $data->description, $language);
+}
+
+// Verify that the pid is not less than 1 to in order to continue.
+if ($pid < 1) {
+    widgetOutput('Product ID Not Found');
+}
+
+$configOptionsGroupID = Capsule::table('tblproductconfiglinks')
+    ->where('pid', '=', $pid)
+    ->select('gid')
+    ->first();
+
+$configOptions = Capsule::table('tblproductconfigoptions')
+    ->where('gid', '=', $configOptionsGroupID->gid)
+    ->select('optionname','qtyminimum')
+    ->get();
+
+    widgetOutput($name);
+
+function widgetOutput($value) {
+    echo "document.write('".addslashes($value)."');";
+    throw new ProgramExit();
+}