Virtuemart: get PDF invoice link on order_done step - joomla2.5

I have Joomla 2.5.17 an Virtuemart 2.0.26d. I want the PDF invoice download link on the order_done step which is rendered by order_done.php view.
I already configured the virtuemart so the order status is on "CONFIRMED" - "C" meaning as the order is paced, the PDF invoice had been already generated.

Ok, i got it. So this is what you have to do if you want the download link in order_done step. Assuming your PDFs are stored in "media/vmfiles/invoices/" you need to add some code to components/com_virtuemart/controllers/cart.php line about 477 where "else if($task=='confirm')" block starts:
...
$cart->confirmDone();
$view = $this->getView('cart', 'html');
$securePath = VmConfig::get('forSale_path',0);
$segments = explode('/', $securePath);
$folderOnServer = $segments[sizeof($segments)-3].'/'.$segments[sizeof($segments)-2];
$orderModel = VmModel::getModel('orders');
$invoiceId = $orderModel->getInvoiceNumber($cart->virtuemart_order_id);
$pdfName = "{$folderOnServer}/invoices/vminvoice_{$invoiceId}.pdf";
$view->setLayout('order_done');
$view->pdfName = $pdfName;
$view->display();
...
also a bit code in view templates/{yourtheme}/html/com_virtuemart/cart/order_done.php:
<div class="get-pdf"><?php echo JText::_('get_your_pdf'); ?> <?php echo JText::_('DOWNLOAD_PDF') ?> <br/></div>

Related

TYPO3 get category uid at FLUID template (sys_category)

I try to show my category uid or name as a class="category.uid" at my FLUID template.
If I try <f:debug>{data}</f:debug> I'll see there are an output like: categories => '1' (1 chars)
But how can I write the category-uid or -name into my FLUID/HTML, similar like this:
<div id="container" class="{data.nav_title}">
<!-- I need the categories -->
<div id="container" class="{categories.uid}">
THanks for your help.
EDIT: some screenshots
The info is in table sys_categorytitle, uid, pid ..
`{data}
The same problem is discussed here (see 11:30 - 12:31).
So there is no viewhelper for this. You have to register a ContentController with Flux.
I have used a variant of the solution here: How can I get the category object in Fluid of Typo3 Content Element Pictures?
TypoScript
lib.categories = CONTENT
lib.categories {
table = sys_category
select {
pidInList = root
selectFields = sys_category.uid
join = sys_category_record_mm on sys_category_record_mm.uid_local = sys_category.uid
where.field = recordUid
where.wrap = sys_category_record_mm.uid_foreign=|
}
renderObj = COA
renderObj {
1 = TEXT
1 {
field = uid
stdWrap.noTrimWrap = | cat-||
}
}
}
Fluid Template
<f:cObject typoscriptObjectPath="lib.categories" data="{recordUid: data.uid}" />
Sorry for the answer - i do not have enough reputation to comment.
What is {data}?
Is it something you get from your controller like?
$data = $this->configurationManager->getContentObject()->data;
$this->view->assign('data', $data);
If so, then you will need to do some extra processing in your controller since $data is an associated array and not an object / model with injection of relations.

How can I post FileInfo to a web service using Yesod and Http-Conduit?

I am working with the default Yesod scaffolding project.
I have created a page that displays a simple form to upload files.
(The form will likely be created on the client using Javascript.)
For brevity, the form has a single file input:
<form method="post" action=#{UploadR}>
<input type="file" name="myfile">
<button type="submit">
My objective is to process the form data and then upload the file to a web service.
I have no trouble processing the form, my concern is interacting with the web service.
For example, given the following Yesod handler:
postUploadR :: Handler Html
postUploadR = do
mgr <- fmap httpManager getYesod
fi <- runInputPost $ ireq fileField "myfile"
let fSource = fileSource fi
fName = fileName fi
req <- parseUrl "http://webservice/upload"
let areq = req { method = methodPost
, requestBody = requestBodySourceChunked fSource
}
res <- httpLbs areq mgr
defaultLayout $ do
setTitle "file uploaded"
[whamlet|
<h3> Success
<p> You uploaded #{fName}.
|]
The webservice returns the error: fail post content-length, but everything else works as expected. Perhaps the server doesn't support a chunked request body?
I think your guess about chunked request body is correct. What you need to do is:
Stream the uploaded contents into a temporary file.
Get the size of that file.
Use requestBodySource and provide the file length and its contents.
Fortunately, steps (1) and (2) can be handled quite easily by the sinkCacheLength function. You'll end up with something like:
(fSize, fSource) <- fileSource fi $$ sinkCacheLength

How to get the content of an article via a webservice on Joomla 2.5

I need to get the content of an Article which is on my Joomla website. In order to do this, I was planning to write a simple PHP webservice to get the content (HTML) of my article. But I just don't know how to do this.
I'm new in Joomla, web developping and web services. I just want to get the content of my article in order to display it in my ruby on rails site. Can anyone explain how I can do this?
Well, here is at least a small contribution that should help to get you going: the attached code can be called with "?id={ID of article you want to retrieve}" and it displays the entire object on screen.
Next steps: pick out the pieces you're interested in and return these...
<?php
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);
$username="*** insert username ***";
$password = "*** password here ***";
if (!defined('_JDEFINES')) {
define('JPATH_BASE', dirname(__FILE__));
require_once JPATH_BASE.'/includes/defines.php';
}
require_once JPATH_BASE.'/includes/framework.php';
// Mark afterLoad in the profiler.
JDEBUG ? $_PROFILER->mark('afterLoad') : null;
// Instantiate the application.
$app = JFactory::getApplication('site');
// Initialise the application.
$app->initialise();
$app ->login(
array('username'=>$username,
'password'=>$password),
array('remember' => true));
$dbo = JFactory::getDBO();
$id=$_GET["id"];
$art = JTable::getInstance('Content');
$art->load($id);
echo "<pre>";
var_dump($art);
echo"</pre>";
?>

Prestashop 1.5 Cookie content

I need to display prestashop customer ID in an external PHP page.
In the official documentation http://doc.prestashop.com/display/PS15/Diving+into+PrestaShop+Core+development)
I found the php code:
If you need to access the PrestaShop cookie from non-PrestaShop code, you can use this code:
include_once('path_to_prestashop/config/config.inc.php');
include_once('path_to_prestashop/config/settings.inc.php');
include_once('path_to_prestashop/classes/Cookie.php');
$cookie = new Cookie('ps'); // Use "psAdmin" to read an employee's cookie.
So i tryed:
include_once('config/config.inc.php');
include_once('config/settings.inc.php');
include_once('classes/Cookie.php');
$cookie = new Cookie('ps');
$id_client = $cookie->id_customer;
echo $id_client;
But nothing is displayed, I tried other tokens, only "date_add" works
What's wrong with my code?
The following works:
global $smarty;
global $cookie;
include(dirname(__FILE__).'/config/config.inc.php');
include(dirname(__FILE__).'/header.php');
$cookie = new Cookie('ps');
$id_client = $cookie->id_customer;
echo $id_client;
include(dirname(__FILE__).'/footer.php');
I tested it myself. Everything including id and firstname works. It seems you should not include classes/Cookie.php file. Instead, replace it with global $cookie Make sure to change the directory of the included files.

Opencart how to add everything from the language file in php loop

It there a way to read everything from within a language with Opencart?
At the moment I have to:
Controller
$this->load->language('help');
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['tab1'] = $this->language->get('tab1');
Language File
<?php
// Heading
$_['heading_title'] = 'Help';
$_['tab1'] = 'Account';
?>
The easiest thing to do is to use array merge at the top of your controller
$this->data = array_merge($this->data, $this->language->load('language/file'));
or simply
$this->data += $this->language->load('language/file');
Edit
For 2.x, use
$data = array_merge($this->data, $this->language->load('language/file'));
3.x does this automatically
In system/library/language.php is a
function to get everything called all().
This is how to get a single item:
$var = $this->language->get('heading_title');
This returns an array with all language entries:
$var = $this->language->all();