opencart 1.5.5.1 how change on normal link? See on picture http://i.imgur.com/H9krDbT.jpg
link in administration order to edit items (admin/index.php?route=catalog/product/update&token=4d93b21563db6a6c5fe44b7c365c210b&product_id=54), this is bad, how change on normal link (index.php?route=product/product&product_id=54)
$action = array();
$action = array(
'text' => [[Pass_text_value]],
'href' => $this->url->link('catalog/product/update', 'token=' . $this->session->data['token'] . '&product_id=' . [[Pass_product_id_here]] . $url, 'SSL')
);
See this is the only way you should pass actions like EDIT from the controller to template. The whole link will not be displayed but only the passed text.
If you are passing more than one instances to template then put these whole code inside your foreach loop and change $action = array( to $action[] = array(.
Related
When a custom attribute is set on a user from googles admin page I am unable to see it in their Google_Service_Directory_User object the client has this scope and is able to see the users data but no attributes are shown.
$client->setScopes(
[
Google_Service_Directory::ADMIN_DIRECTORY_USER_READONLY,
Google_Service_Directory::ADMIN_DIRECTORY_GROUP_READONLY,
]
);
I would have expected it to be in the customSchemas but that is null for all the users
When requesting user's informations, you need to set the projection parameter to FULL when using the method users.get (projection parameter is also avaible with method users.list). Default settings to not return custom schemas. You can have more informations here (Google documentation).
You seem to be using PHP (I've never coded in PHP so I may be wrong), so the request should look like this:
$optParams = array(
'userKey' => 'my_customer#example.com',
'projection' => 'full', // or maybe 'FULL' ?
);
$results = $service->users->get($optParams);
If you only want the return some of the schemas, then use :
$optParams = array(
'userKey' => 'my_customer#example.com',
'projection' => 'custom', // or maybe 'CUSTOM' ?,
'customFieldMask' => 'A comma-separated list of schema names'
);
$results = $service->users->get($optParams);
Right now in opencart the system is limited to only showing 2 levels of categories. Does anyone know of a class to get all sub-categories and a full ul li tree?
For example: If you have ever used oscommerce it will show the full tree of sub-cats in the side category menu where as opencart is limited to only two levels.
The default code is like
$categories = $this->model_catalog_category->getCategories(0);
foreach ($categories as $category) {
$children_data = array();
if ($category['category_id'] == $data['category_id']) {
$children = $this->model_catalog_category->getCategories($category['category_id']);
foreach($children as $child) {
$filter_data = array('filter_category_id' => $child['category_id'], 'filter_sub_category' => true);
$children_data[] = array(
'category_id' => $child['category_id'],
'name' => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])
);
}
}
However it only goes two levels, I am looking for all levels to build out an accordion menu.
Further I am not looking for someone to do this, (unless you want), but maybe you can point me in the right direction or to an existing class that will achieve this.
You'll need to add each sub-level manually for a 3rd, for a 4th etc. There is no way to just get all of them in one shot.
There was an older stackoverflow thread with a solution on how to add a 3rd level. Perhaps it will work with your version of OC:
get third level category in opencart 2
You basically will need to edit the controller and tpl files for category. If that's too much for you, they sell an extension on their marketplace for it, too.
I'm developing a plugin that lets me add and delete custom table records. Adding and deleting records works fine.
I also want to be able to update the records. This is where I cannot figure out what I'm doing wrong.
Here is my update code if anyone can point me in the right direction (I'm currently focused on the "update selected record" script:
function url_update() {
global $wpdb;
$id = $_GET["id"];
$launchname=$_POST["launchname"];
$url1 = $_POST["url1"];
$url2 = $_POST["url2"];
$urluser = $_POST["urluser"];
$urlpwd = $_POST["urlpwd"];
$wpfirstname = $_POST["wpfirstname"];
$wplastname = $_POST["wplastname"];
$wpemail = $_POST["wpemail"];
$activated = $_POST["activated"];
//update selected record
if(isset($_POST['update'])){
$wpdb->update('launcher',
array(
'id' => $id,
'launchname' => $launchname,
'url1' => $url1,
'url2' => $url2,
'urluser' => $urluser,
'urlpwd' => $urlpwd,
'wpfirstname' => $wpfirstname,
'wplastname' => $wplastname,
'wpemail' => $wpemail,
'activated' => $activated
),
array( 'ID' => $id ), //this line fixed the issue
array('%d','%s','%s','%s','%s','%s','%s','%s','%s','%s'));
}
//delete
else if(isset($_POST['delete'])){
$wpdb->query($wpdb->prepare(
"DELETE FROM wp_tincan_launcher WHERE id = %d",$id
));
}
else{
//selecting row to update
$selected_record = $wpdb->get_results($wpdb->prepare(
"SELECT id,launchname,url1,url2,urluser,urlpwd,wpfirstname,
wplastname,wpemail,activated from launcher where id=%d",$id
));
foreach ( $selected_record as $s ){
$launchname=$s->launchname;
$url1=$s->url1;
$url2=$s->url2;
$urluser=$s->urluser;
$urlpwd=$s->urlpwd;
$wpfirstname=$s->wpfirstname;
$wplastname=$s->wplastname;
$wpemail=$s->wpemail;
$activated=$s->activated;
}
}
I think my code is correct, however, I would really appreciate some feedback that directly addresses my code.
EDIT: Thanks to Pekka for pointing out that I did not identify the error results.
The Error I'm getting from WP is "Notice: Undefined index: each column in the DB."
Best Regards
I resolved it myself by changing my update query to include a new line as follows: array( 'ID' => $id ), before the types line.
None of the links I was led to, not any of the generic advice I was provided was of any help what-so-ever.
I've edited the original code to reflect the complete working code.
I have a method in a class that scans a directory and creates an array of all the subdirectories. It's pretty simple and works great. However, I would like to add a unit test for this method and I am having a hard time figuring out how.
Here's my problem: I can create a virtual file system using vfsstream and it works fine. However, I can't pass that to my class to create an array from. It needs a real directory to scan. I want to test against a controlled directory (obviously so I know exactly what will the be result of every scan so I can test it). The scanned directory in production may change frequently.
So, my only solution is to create a test-specific fake directory in my test folders, pass that path to my scanner, and then check it against what I know to be in that fake directory. Is this best practice or am I missing something?
Thank you!
Here is some code:
The Test
function testPopulateAuto()
{
$c = new \Director\Core\Components\Components;
// The structure of the file system I am checking against. This is what I want to generate.
$check = array(
'TestFolder1',
'TestFolder2',
);
$path = dirname( __FILE__ ) . "/test-file-system/"; // Contains TestFolder1 and TestFolder1
$list = $c->generateList( $path ); // Scans the path and returns an array that should be identical to $check
$this->assertEquals($check, $list);
}
Sorry if I misunderstood your question, but scandir should work with custom stream. Example:
$structure = array(
'tmp' => array(
'music' => array(
'wawfiles' => array(
'mp3' => array(),
'hello world.waw' => 'nice song',
'abc.waw' => 'bad song',
'put that cookie down.waw' => 'best song ever',
"zed's dead baby.waw" => 'another cool song'
)
)
)
);
$vfs = vfsStream::setup('root');
vfsStream::create($structure, $vfs);
$music = vfsStream::url('root/tmp/music/wawfiles');
var_dump(scandir($music));
Output:
array(5) {
[0]=>
string(7) "abc.waw"
[1]=>
string(15) "hello world.waw"
[2]=>
string(3) "mp3"
[3]=>
string(24) "put that cookie down.waw"
[4]=>
string(19) "zed's dead baby.waw"
}
I want to display the currency list on the product description page. How can I do that?
I copied the code from header.tpl () and pasted it in the product.tpl but I get an error:
Notice: Undefined variable: currency in C:\xampp\htdocs\mysite.com\catalog\view\theme\mytheme\template\product\product.tpl on line 60.
I tried adding the following code in product.tpl.
<?php include(DIR_APPLICATION.'\view\theme\mytheme\template\module\currency.tpl');
but that did not work either. Please help as I want to get this working.
controller/common/header.php function index() add in to:
$this->data['mygetcurrency'] = $this->currency->getCode();
catalog\view\theme\default\template\common\header.tpl add in to:
<?php echo $mygetcurrency; ?>
//EUR
i guess this can be the easiest way.
<?php echo $this->currency->getSymbolRight($this->session->data['currency']) ?>
OR
<?php echo $this->currency->getSymbolLeft($this->session->data['currency']) ?>
The best will be to do like this
$this->load->model('localisation/currency');
$this->data['allcurrencies'] = array();
$results = $this->model_localisation_currency->getCurrencies();
foreach ($results as $result) {
if ($result['status']) {
$this->data['allcurrencies'][] = array(
'title' => $result['title'],
'code' => $result['code'],
'symbol_left' => $result['symbol_left'],
'symbol_right' => $result['symbol_right']
);
}
}
thanks
The $currency variable is built by the /catalog/controller/module/currency.php controller, which is normally called by /catalog/controller/common/header.php (using $this->children array).
To display this element in the product template, you'll need to call on this controller (and its view) using the $this->children array of the product controller (/catalog/controller/product/product.php). In opencart 1.5.4.1, it's around line 362
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header',
'module/currency' // Just add this line
);
Unfortunately, this will display the currency element at the top of the page by default, because this element's style is set to absolute positioning. You'll need to edit /catalog/view/theme/*/template/module/currency.tpl to make the HTML and CSS a bit more flexible.
you can use very simple code. add this in your controller file.
$data['currency-symbol'] = $this->currency->getSymbolLeft($this->session->data['currency']);
And now you can echo it in your related .tpl file using this
<?php echo $currency-symbol ;?>