Question

I'm using the Shopp E-commerce plugin for Wordpress

I want to use some data that is provided by this plugin. I want to use the payment method in a PHP if statement. To do this I need to get the data in a variable

The plugin provides only a piece of code that actually displays the value.

<?php shopp('purchase', 'paymethod'); ?>

But I want to have this data in a variable

$paymentmethod = ...

I'm having problems to get the shopp data in the variable. How can I do this?

Solved:

Great, you helped me out a lot. This is what i got: For future reference this translates the payment method provided by the shopp plugin to another description that is needed for an integration with the trusted shops certificate. It probably could be a lot cleaner but this works.

<?php 
$paymentmethod = shopp('purchase', 'paymethod',  array('return'=>true)); 
if ($paymentmethod == vorkasse)
echo "PREPAYMENT";
else 
echo "OTHER PAYMENT";
?>
Was it helpful?

Solution

If I read the manual, there is an 'options' parameter you can use. Read the manual for more information (I can't test this for you, I don't have an install), but it will look something like this

$paymentmethod = shopp('purchase', 'paymethod', array('return'=>true)); 

You should play around a bit, because it is not completely clear how this works. There is also the 'echo' option, which does the reverse of the return option (I think), but the manual says it does so on false. That would be strange.

return: when set to true, 1, or on, this option forces the tag to return the value instead of displaying/echoing the value to the page. Alternatively, prefix the tag parameter with get to get the same effect. All theme api tags that return a boolean value will return by default.
echo: when set to false, 0, or off, this option forces the tag to display the value to the page. This is the default for all non-boolean tags.

You might need to provide the 'echo' paramter as wel. But some combination of these should work :)

OTHER TIPS

A shorthand for writing shopp() commands has been added to the Shopp API.

This: $paymentmethod = shopp('purchase', 'paymethod', 'return=true');

can now be written as: $paymentmethod = shopp('purchase.get-paymethod');

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top