Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Press One Button, But Initiate Two Commands Rate Topic   - - - - -

 
  • larrezz91
  • Advanced Member
  • Trial users
  • Join Date: 23-Oct 14
  • 53 posts

Posted 08 March 2016 - 01:50 PM #1

I was wondering, is it possible to initiate two commands with one button? Let me clearify that:

 

I want to to make a page with some text, a field for the coupon code and a button that automatically adds a predefined product to the shopping cart along with a coupon code automatically applied to the price. I have tried something with the code below, but without success.

<form class="cm-ajax cm-ajax-force cm-ajax-full-render" name="coupon_code_form" action="http://www.example-server.com/" method="post">
	<input type="hidden" name="result_ids" value="checkout*,cart_status*,cart_items,payment-methods">
	<input type="hidden" name="redirect_url" value="index.php?dispatch=checkout.cart">
	<input type="hidden" name="product_data[13560][product_id]" value="13560">
	<div class="ty-gift-certificate-coupon ty-discount-coupon__control-group ty-input-append error">
		<label for="coupon_field" class="hidden cm-required">Promotion code</label>
		<input type="text" class="ty-input-text cm-hint" id="coupon_field" name="coupon_code" size="40" value="">
		<button title="Apply" class="ty-btn-go" type="submit"><i class="ty-btn-go__icon ty-icon-right-dir"></i></button>
		<input type="hidden" name="dispatch" value="checkout.apply_coupon">
	</div>
</form>

Thank you in advance,

 

Allan



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11664 posts

Posted 08 March 2016 - 09:55 PM #2

I would do this on the backend when the form is processed.  I.e. put the product you want in the cart and then apply the coupon and return the user to wherever you want them to be.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • larrezz91
  • Advanced Member
  • Trial users
  • Join Date: 23-Oct 14
  • 53 posts

Posted 09 March 2016 - 08:13 AM #3

Thanks for your reply tbirnseth. I will give it a try this way. 



 
  • pradeesh_72
  • Member
  • Trial users
  • Join Date: 15-Nov 17
  • 45 posts

Posted 01 January 2018 - 05:13 AM #4

I have a similar problem. I want to show a dashboard on home page when a user logs in. Is there any way to pass two result_ids and update them both with different contents?
 



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11664 posts

Posted 01 January 2018 - 10:41 PM #5

Resultids are comma separated. You can press as many as you want.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • pradeesh_72
  • Member
  • Trial users
  • Join Date: 15-Nov 17
  • 45 posts

Posted 03 January 2018 - 05:40 AM #6

Well, My problem is, how can I decide which content goes to which?



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11664 posts

Posted 03 January 2018 - 08:37 PM #7

Would need more info on what you have and what you want to do in order to discuss.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • pradeesh_72
  • Member
  • Trial users
  • Join Date: 15-Nov 17
  • 45 posts

Posted 05 January 2018 - 04:12 AM #8

Let's say, I have two divs in home page. I want to update one with the previous orders of the user and second with his profile when he logs in. When he logs out, it should show static content. This can be easily achieved by reload / redirect. I wanted to know if there is a way to do it using ceAjax.



 
  • galtinbaeva
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 06-Dec 13
  • 3419 posts

Posted 05 January 2018 - 07:14 AM #9

Let's say, I have two divs in home page. I want to update one with the previous orders of the user and second with his profile when he logs in. When he logs out, it should show static content. This can be easily achieved by reload / redirect. I wanted to know if there is a way to do it using ceAjax.

 

Hello!

 

There is a redirect after login and logout, do you really need ajax? Anyway, you can return the variable used in these blocks in your controller and specify block IDs in the result_ids parameter.There is no need to specify which data goes to which block because blocks use certain variables that should be updated.


Simtech Development | sales@simtechdev.com | www.simtechdev.com
CERTIFIED CS-CART PARTNER | LICENSES | DEVELOPMENT | ADD-ONS | DESIGN | UPGRADE

Google Analytics Enhanced Ecommerce - get advanced ecommerce analytics


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 20788 posts

Posted 05 January 2018 - 07:30 AM #10

As alternative with result_ids you can use the following code after ajax request is completed

Tygh::$app['view']->display('PATH_TO_TEMPLATE1');
Tygh::$app['view']->display('PATH_TO_TEMPLATE2');
exit;

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11664 posts

Posted 05 January 2018 - 08:54 PM #11

I'd just use standard html blocks with smarty support and let the block carry the logic on what to display depending on whether the user is logged in or not.  Each would be conditional upon {$auth.user_id != 0} for a logged in user.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.