opencart duplicate shipping methods - duplicates

I've just duplicated the flat and free shipping methods.
I've changed everything in all the files (litteraly everything from flat to flat2 etc)
I've cleared all caches, including the modifications and vqmod cache, but I can't enable the duplicated methods.
When I echo to test when trying to activate I get:
Array(
[shipping_flat_cost] => 19
[shipping_flat_tax_class_id] => 0
[shipping_flat_geo_zone_id] => 6
[shipping_flat_status] => 1
[shipping_flat_sort_order] => )
So it still refers to flat instead of flat2.
Have I missed something?
Thanks!

Related

Incomplete JSON data on GET request in ASP.NET Core

Why I get not all data from base by link
https://localhost:XXXXX/api/comments
(GET request)
After update page data no longer appears ..
Responce:
[{"id":1,"text":"Comment1","userId":1,"parentCommentId":null,"user":null,"parentComment":null,"childrenComments":null},{"id":2,"text":"Comment2","userId":1,"parentCommentId":1,"user":null,"parentComment":{"id":1,"text":"Comment1","userId":1,"parentCommentId":null,"user":null,"parentComment":null,"childrenComments":[
Does not load subordinate item ..
What am I doing wrong?
// GET: api/Comments
[HttpGet]
public IEnumerable<Comment> GetComments()
{
return _context.Comments;
}
You must load the relationships as well. The two primary ways of doing that are eager-loading via Include or lazy-loading. However, lazy-loading should be avoided in general, and especially so in cases like this. When you're serializing an object, you could end up issuing hundreds or even thousands of queries inadvertently with lazy-loading.
Long and short, add Include clauses for the relationships you care about:
return _context.Comments
.Include(x => x.User)
.Include(x => x.parentComment)
.Include(x => x.childrenComments);
If you want more flexibility, you can employ either OData or GraphQL. Either will allow the client to selectively include the relationships they want/need, meaning you won't necessarily need to join everything every time.

how can I upload csv file in wordpress 4.9.9 upwards

recent security changes have made my csv upload not work saying that the type is invalid. I need to bypass this change but have failed to do by adding the mime type to the relevant filters.
function my_myme_types($mime_types){
$mime_types['csv'] = 'text/csv'; //Adding csv extension
return $mime_types;
}
add_filter('upload_mimes', 'my_myme_types', 1, 1);
It is a bug -- or security "feature" depending whom you ask -- in WordPress 4.9.9 and 5.0.1 core.
The quick fix -- add this to wp-config.php
define(‘ALLOW_UNFILTERED_UPLOADS’, true);
This will open potential security risks by stopping the "newly enhanced" WordPress file type checking, but not more of a risk thank WP 4.9.8 or 5.0 came with.
Remember to turn this to false if WordPress fixes the CSV bug.
You can read more details and follow related threads in this article for my user base.
You may also try adding this to theme or plugin code but it fundamentally changes the way the mime type system works in WordPress. Fixes the issue but you may have more long term problems if you keep this in place:
function fix_wp_csv_mime_bug( $data, $file, $filename, $mimes ) {
$wp_filetype = wp_check_filetype( $filename, $mimes );
$ext = $wp_filetype['ext'];
$type = $wp_filetype['type'];
$proper_filename = $data['proper_filename'];
return compact( 'ext', 'type', 'proper_filename' );
}
add_filter( 'wp_check_filetype_and_ext', 'fix_wp_csv_mime_bug', 10, 4 );

Using Prawn with Sinatra

How can I use Prawn to generate PDF of form data in Sinatra?
My form is at the index action of the site but Prawn doesn't recognize the variables passed in. I've found this code in the documentation at http://prawnpdf.org/docs/0.11.1/Prawn/Document.html.
get '/download' do
content = "Hello World"
Prawn::Document.generate "example.pdf" do |pdf|
pdf.font "Times-Roman"
pdf.draw_text content, :at => [200,720], :size => 32
end
end
Now this is great, but when I try to pass in my variables from the parameters like this:
post '/resume' do
#name = params.fetch 'name'
...
end
And then if I add that into the /download route like this:
get '/download' do
Prawn::Document.generate "example.pdf" do |pdf|
pdf.font "Times-Roman"
pdf.draw_text #name, :at => [200,720], :size => 32
end
end
It it will draw nothing. Also, weirdly, it generates a pdf file but doesn't redirect to it and I have to manually load it.
Really stuck on this one - advice?
Every request creates a new instance of your Sinatra app to serve it. Therefore, instance variables won't be the same across 2 different requests. You either need to persist the data using one of the many ways to do this (cookies, local storage, database, cache etc) or you need to put the Prawn logic in the POST route.

ZF2 Configuration Injection Or NOT?

I've googled a lot and read as much as I can on the subject but I cannot find a direct answer to my question anywhere including here. My ZF2 application consists of roughly 7 different modules. 5 of the modules will need access to the same database configuration. The application itself has a database with roughly 124 different tables. So the idea here is to find the proper solution to write the least amount of code considering the setup.
What I'm trying to do is create a specific class to interface with the DB. Where the business logic is kept in the Module and note the controllers to keep everything more abstract and easier to maintain. By that I mean controller X should be able to create a new instance of for instance (Application\Model\DBInterface) and use the models functions to do inserts deletes updates joins selects and so forth. The reason I would like to do it this way is so that all modules installed can use the same interface without having to write endless DI statements everywhere. So what I will need is an example of how I can get the configuration for the DB (currently inside module.config.php + local.php(username / pw)) to be passed to the Application\Model\DBInterface dbConfig variable, and perhaps even an instance of the dbAdapter initialized from config if possible.
Alternatively I could potentially grab the configuration from the Application\Model\DBInterface if such a way exists.
If neither of the above is possible then I can always go back to the old way of doing things by reading an ini file for the db details and instantiating my db adapter that way.
Please keep in mind that I won't be injecting anything in the controllers as the controllers just use $db = new \Application\Model\DBInterface() so injecting into the controllers doesn't make much sense at all.
Is there a better way to do this / optimized / am I doing it completely wrong? Anyone able to share some details please. I've spent way too much time on this already and definitely need help.
Okay, so #Ocramius did just let me know what my misconception with the initializers was and helped me out a bit in understanding it. So here is a probably working solution to your Problem. My understanding about your problem is:
"How to get a DbAdapter set for all your Models implementing a DbInterface". This is how you'd do it:
Step 1: Create invokables for all classes implementing the DbInterface. Create a factory for the default Zend\Db\Adapter\Adapter and then create an initializer for your DbInterface
Module.php getServiceConfig()
return array(
'invokables' => array(
'application-model-one' => 'Application\Model\One',
'application-model-two' => 'Application\Model\Two'
),
'factories' => array(
'Zend\Db\Adapter\Adapter' => 'Zend\Db\Adapter\AdapterServiceFactory'
),
'initializers' => array(
'DbInterfaceInitializer' => function($instance, $sm) {
if ($instance instanceof \Application\Model\DBInterface) {
$instance->setDbAdapter($sm->get('Zend\Db\Adapter\Adapter'));
}
},
)
)
The Zend\Db\Adapter\Adapter is using the top-level-configuration-array-key 'db' to automatically inject the dbParams
Step 2: Create your classes implementing your Interface
Application\Model(One|Two|N).php
namespace Application\Model;
class One implements DbInterface, \Zend\Db\Adapter\AdapterAwareInterface
{
/**
* #var \Zend\Db\Adapter\Adapter $dbAdapter
*/
protected $dbAdapter;
public function setDbAdapter(\Zend\Db\Adapter\Adapter $dbAdapter) {
$this->dbAdapter = $dbAdapter;
}
public function getDbAdapter() {
return $this->dbAdapter;
}
// More of your business logic or data here
}
Step 3: Access those classes with the ServiceLocator from your Controllers
SomeController.php someAction()
$dbOne = $this->getServiceLocator()->get('application-model-one');
$dbTwo = $this->getServiceLocator()->get('application-model-two');
// Adapter will automatically be injected
When accessing the invokable from the ServiceManager the initializer will be called. The initializer then will automatically call the Zend\Db\Adapter\Adapter, which in turn get's the parameters from the configuration key 'db'
You may get more information from once the tutorial Application as well as the blog of
samsonasik: ServiceManager Cheat-Sheet

I am having trouble saving an array in a Rails 2.2.2 app

in the controller:
#reminders = Reminder.find(:all, :conditions => ["group_id = ? and remind_at < ?", g.id, #three_days_ago])
#reminders.each do |r|
r.remind_at = DateTime.now
end
#reminders.each(&:save!)
p "*** test ***"
This approach is working in another part of my code, but for some reason there is no error message but the data is not saving. It is not an attributes accessible problem. The test message is printing in the console so the process is not skipping over that part of the code. Is my syntax correct?
This should work, but it's not a very efficient way of doing things. You could potentially have a very large number of reminders which could potentially require multiple GBs of memory to load. Fetching all of anything is inherently risky.
A better solution is to just get the database to do it:
Reminder.update_all(:remind_at => Time.now)
Even on a large table, this operation should complete fairly quickly and doesn't require loading, adjusting, validating and saving each model.