Jump to content

How to access information from an external URL?


Recommended Posts

Hi,

 

from an external URL I fill the cart in PS 1.5.4.1 with one item. I use a form like this:

 

<form action="www.shop.com/index.php?controller=cart" method="post">
 <p class="hidden">
  <input type="hidden" name="id_product" value="2" id="product_page_product_id" />
  <input type="hidden" name="add" value="1" />
  <input type="hidden" name="id_product_attribute" id="idCombination" value="" />
  <input type="hidden" name="qty" id="quantity_wanted" class="hidden" value="1" size="2" maxlength="3"  />
  <input type="hidden" class="hidden" name="firstname" id="firstname" value="abc" />
  <input type="hidden" class="hidden" name="lastname" id="lastname" value="xyz" />
 </p>   
 <br />
 <input type="image" src="logo_td24_300x64.jpg" alt="Send">
</form> 

 

At the same time I passed customer's firstname and lastname with the form. The item is created
in the cart, but I can't access customer's name. My question is: in which file I need query the
name and how? I want to use it in the shopping-cart.tpl.

 

Does anyone have an idea or tip for me?

 

Thank you

Link to comment
Share on other sites

action should contain http protocol, action="http://address" instead of just action="www.shop.com/index.php?controller=cart"

  Quote

 

 

 The item is created
in the cart, but I can't access customer's name. 

where you want to access customers name? in ps?

and what if customer will not be logged in to your shop?

Link to comment
Share on other sites

Hi Vekia,

 

thank you for your quick response!

 

ok, "http" should stand in front of, is unfortunately lost when copying the URL.

 

Yes, I want to access customers name in ps. Background is as follows:
Customers buy products in an another shop. There they are logged in
and pay and after buying they have to pay transport at another provider.
So you click on a link after purchase and come on the side where it is
sold transportation. This is also a Presta Shop and the products are the
transports. The name and address I know now by buying from the other store
and the customer no longer needs to login.

 

I hope I have made myself clear for the background.

 

Also, I've tried a few things but they did not succeed:

In the init function of CartController.php
$this-> Tools = testvar :: getValue ('firstName');
and then
In shopping cart.tpl
Test: {$ cart-> testvar} -> empty / nothing

 

But it doesn't work. How can I read post-informations in shopping-cart.tpl ?

Link to comment
Share on other sites

Hi Vekia,

 

I've tried it and put var_dump($ _POST) into the file classes\cart.php.

The result was that the array is completely empty! But it was created

still the right item in Cart. Something MUST have been postet, otherwise
no item is created. Should I try var_dump in another PHP file?

Link to comment
Share on other sites

Hi,

 

ok, I have tested var_dump now in the file classes\controller\FrontController.php
and all information are displayed that have been posted.

 

Then I tried in FrontController.php:
$this->context->smarty->assign('testvar', "Hello");

and display in the file shopping-cart.tpl:
<div>
 show me: {$testvar}
</div>

This works fine.

 

But that doesn't work:
$this->context->smarty->assign('testvar', Tools::getValue('firstname'));
and
$this->context->smarty->assign('testvar', $_POST['firstname']);
Both show nothing

 

How can I access the POST variables?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...