X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Get attribute multi values from attribute name ? (https://forum.x-cart.com/showthread.php?t=76507)

lakin1 09-04-2018 02:34 AM

Get attribute multi values from attribute name ?
 
Hi ,
I am developing a custom module to get attribute multi select values from its name .

I am not able to find any inbuilt functions to do so.

Any suggestions will be greatly appreciated.

Thanks,
Lakin
Xcart 5.3.5.5

cflsystems 09-04-2018 05:16 AM

Re: Get attribute multi values from attribute name ?
 
Try doing a search - see

classes/XLite/Model/Repo/Attribute.php
protected function prepareCndName


classes/XLite/Model/Repo/AttributeOption.php
public function findOneByNameAndAttribute

lakin1 09-04-2018 09:43 AM

Re: Get attribute multi values from attribute name ?
 
Quote:

Originally Posted by cflsystems
Try doing a search - see

classes/XLite/Model/Repo/Attribute.php
protected function prepareCndName


classes/XLite/Model/Repo/AttributeOption.php
public function findOneByNameAndAttribute


Thanks . It really helped.

Can we place indivisual add to cart buttons for each attribute ?
If yes , then how can we handle add to cart.
Please suggest.

cflsystems 09-04-2018 10:05 AM

Re: Get attribute multi values from attribute name ?
 
I am sure you can. You have to see how the product has the button and what params passes to it for the action "add to cart".
However it may be a little bit tricky to do that for each variant - depends where you have the list.
XC is coded so almost the whole page is inside "form" tag - this was mentioned to them years ago as something that should not be this way but it is still like this. They may never fix it. You will have to have the list outside the form for starter and then call the add to cart widget for each item in the list with its own parameters.

lakin1 09-04-2018 10:40 AM

Re: Get attribute multi values from attribute name ?
 
Quote:

Originally Posted by cflsystems
I am sure you can. You have to see how the product has the button and what params passes to it for the action "add to cart".
However it may be a little bit tricky to do that for each variant - depends where you have the list.
XC is coded so almost the whole page is inside "form" tag - this was mentioned to them years ago as something that should not be this way but it is still like this. They may never fix it. You will have to have the list outside the form for starter and then call the add to cart widget for each item in the list with its own parameters.


<form action="?target=cart" method="post" accept-charset="utf-8" class="custom-add2cart">
<input type="hidden" name="target" value="cart" />
<input type="hidden" name="action" value="add" />
<input type="hidden" name="product_id" value="{{this.getProduct().getId()}}" />
<input type="hidden" name="attribute_values[{{attribute['id']}}]" value="{{attribute['select_attribute_id']}}" />
<div class="add-button-wrapper widget-fingerprint-product-add-button">
<button type="submit" class="btn regular-button regular-main-button add2cart submit">
<span>Add to cart</span>
</button>
</div>
</form>


I added above code and its adding product attribute as per its value.
But i ma facing one problem with price.
I mean , how can i override default product price calculation per attribute ?


All times are GMT -8. The time now is 09:53 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.