Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

how I add a new field to orders in admin area ?

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #11  
Old 07-04-2016, 12:52 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: how I add a new field to orders in admin area ?

You should change your Product class as follows:
PHP Code:
<?php
// vim: set ts=4 sw=4 sts=4 et:

namespace XLite\Module\EBLIEB\GlasPak\Model;

class 
Product extends \XLite\Model\Product implements \XLite\Base\IDecorator
{
    
/**
     * @Column (type="string", length=32)
     */
    
protected $PPCField;
    
    
/**
     * Updates "Pieces per case" field.
     * 
     * @param string $value New value
     * 
     * @return void
     */
    
public function setPPCField($value)
    {
        
$this->PPCField $value;
    }

    
/**
     * Returns the value of "Pieces per case" field.
     * 
     * @return string
     */
    
public function getPPCField()
    {
        return 
$this->PPCField;
    }
}

X-Cart 5.3 doesn't add get/set methods automatically, so now you should add these methods manually (if you need them in your modules).
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #12  
Old 08-30-2016, 07:22 AM
  GlasPak's Avatar 
GlasPak GlasPak is offline
 

eXpert
  
Join Date: May 2015
Posts: 241
 

Default Re: how I add a new field to orders in admin area ?

Quote:
Originally Posted by qualiteam
You should change your Product class as follows:
PHP Code:
<?php
// vim: set ts=4 sw=4 sts=4 et:

namespace XLite\Module\EBLIEB\GlasPak\Model;

class 
Product extends \XLite\Model\Product implements \XLite\Base\IDecorator
{
    
/**
     * @Column (type="string", length=32)
     */
    
protected $PPCField;
    
    
/**
     * Updates "Pieces per case" field.
     * 
     * @param string $value New value
     * 
     * @return void
     */
    
public function setPPCField($value)
    {
        
$this->PPCField $value;
    }

    
/**
     * Returns the value of "Pieces per case" field.
     * 
     * @return string
     */
    
public function getPPCField()
    {
        return 
$this->PPCField;
    }
}

X-Cart 5.3 doesn't add get/set methods automatically, so now you should add these methods manually (if you need them in your modules).

Doesn't seem to be working with 5.3

in skins\admin\en\modules\EBLIEB\GlasPak\

I have

Code:
{## # @ListChild (list="invoice.item.name", weight="20") #} {% if this.item.product.getPPCField() %} <li class="ppc-field"> <span class="name">{{ t('Pieces Per Case') }}</span> <span class="ppc-field-value">{{ this.item.product.getPPCField() }}</span> </li> {% endif %}

but it doesn't seem to add to the admin for each product like it did in 5.2 ...

This was based off of
http://devs.x-cart.com/en/basics/adding_new_property_to_a_product/

Any chance this will be updated in the future for 5.3?
__________________
Business License
https://glaspak.com
GoDaddy VPS - Apache with WHM
2GB ECC DDR3 1600MHz
2x Intel E5-2630L v2 Hex Core 2.4/2.8ghz
15 MB proc cache
60 GB 10k RPM hdd
PHP 7.0.15
MariaDB 10.1.21 with InnoDB engine
Reply With Quote
  #13  
Old 08-30-2016, 07:49 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default Re: how I add a new field to orders in admin area ?

The model and page for modify product in 5.3.x changed a lot. While you still should add the new fields to table the set/get functions and where/how fields appear on the modify page in admin require more changes to other (new) classes.

Look at XLite/Model/DTO/Product and XLite/View/FormModel/Product
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following user thanks cflsystems for this useful post:
qualiteam (08-30-2016)
  #14  
Old 08-30-2016, 08:01 AM
  GlasPak's Avatar 
GlasPak GlasPak is offline
 

eXpert
  
Join Date: May 2015
Posts: 241
 

Default Re: how I add a new field to orders in admin area ?

Quote:
Originally Posted by cflsystems
The model and page for modify product in 5.3.x changed a lot. While you still should add the new fields to table the set/get functions and where/how fields appear on the modify page in admin require more changes to other (new) classes.

Look at XLite/Model/DTO/Product and XLite/View/FormModel/Product

This is going to be a huge headache to upgrade unless they change that KB. Also the google adwords order js wont convert over. Took me a while to learn the old system and smarty and now everything is changed again and seems to be more complicated
__________________
Business License
https://glaspak.com
GoDaddy VPS - Apache with WHM
2GB ECC DDR3 1600MHz
2x Intel E5-2630L v2 Hex Core 2.4/2.8ghz
15 MB proc cache
60 GB 10k RPM hdd
PHP 7.0.15
MariaDB 10.1.21 with InnoDB engine
Reply With Quote

The following 2 users thank GlasPak for this useful post:
BrandonLR (08-31-2016), cherie (09-01-2016)
  #15  
Old 09-07-2016, 07:32 AM
  GlasPak's Avatar 
GlasPak GlasPak is offline
 

eXpert
  
Join Date: May 2015
Posts: 241
 

Default Re: how I add a new field to orders in admin area ?

So I moved all the skins to the proper location, changed the decorator and everything that was suggested and it still doesn't work. I uploaded the latest changes. The KB still hasn't been updated eventho my sites are now nagging me to do the 5.3 upgrade (can't until this issue is resolved).
Attached Files
File Type: tar EBLIEB-GlasPak-v5_3_0.tar (13.0 KB, 106 views)
__________________
Business License
https://glaspak.com
GoDaddy VPS - Apache with WHM
2GB ECC DDR3 1600MHz
2x Intel E5-2630L v2 Hex Core 2.4/2.8ghz
15 MB proc cache
60 GB 10k RPM hdd
PHP 7.0.15
MariaDB 10.1.21 with InnoDB engine
Reply With Quote
  #16  
Old 09-27-2016, 09:29 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: how I add a new field to orders in admin area ?

I believe we discussed this in other forum thread.

Anyway, here is the article that explains how you should deal with custom fields on the Edit Product page in X-Cart 5.3.x:
http://devs.x-cart.com/en/basics/adding_new_property_to_a_product/adding_product_property_via_formmodel_api.html
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #17  
Old 09-28-2016, 06:03 AM
  GlasPak's Avatar 
GlasPak GlasPak is offline
 

eXpert
  
Join Date: May 2015
Posts: 241
 

Default Re: how I add a new field to orders in admin area ?

Quote:
Originally Posted by qualiteam
I believe we discussed this in other forum thread.

Anyway, here is the article that explains how you should deal with custom fields on the Edit Product page in X-Cart 5.3.x:
http://devs.x-cart.com/en/basics/adding_new_property_to_a_product/adding_product_property_via_formmodel_api.html


Is your documentation right?

<X-Cart>/classes/XLite/Module/XCExample/NewProductFieldDemo/View/Model/Product.php

Should that be
<X-Cart>/classes/XLite/Module/XCExample/NewProductFieldDemo/View/FormModel/Info.php ?
__________________
Business License
https://glaspak.com
GoDaddy VPS - Apache with WHM
2GB ECC DDR3 1600MHz
2x Intel E5-2630L v2 Hex Core 2.4/2.8ghz
15 MB proc cache
60 GB 10k RPM hdd
PHP 7.0.15
MariaDB 10.1.21 with InnoDB engine
Reply With Quote
  #18  
Old 09-28-2016, 11:08 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: how I add a new field to orders in admin area ?

Ouch. I believe you're right as the code example (that is below the wrong class name) uses the correct one.
I've reported it to the XC5 team.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 02:44 AM.

   

 
X-Cart forums © 2001-2020