CS Cart: How to pass multiple variable from template using assign and recieve them in fucntion in cs-cart - cs-cart

This is working
{assign var="order_notes" value=$order_info.parent_order_id|fn_my_changes_get_order_data}
I am able to use the parent order id in the function but I need to send product id as well. Sp I am using
{assign var="order_notes" value=$oi.product_id+$order_info.parent_order_id|fn_my_changes_get_order_data}
but this is not working. I am able to receive only one variable in my function. Here is the function .
fn_my_changes_get_order_data($order_id,$product_id)
it is working for order_id only when I add product_id there it is showing error. Service unavailable.
Thanks

Its simple. Right format for smarty - {$order_id|fn_my_changes_get_order_data:$product_id}

Related

Create dynamic routes in Laravel

I'm working on ecommerce website, Stuck in nav bar, I have created routes something like this:
Route::get('/category/{slug}', 'Site\CategoryController#show')->name('category.show');
In slug i pass slug of Product,
but i want to change something like this
Route::get('/{slug}/{slug}', 'Site\CategoryController#show')->name('category.show');
i want to remove category prefix and pass main category slug as a first parameter and sub category if it exist as a second parameter otherwise it will be empty.
One more thing i am using TypiCMS, for creating Nestable menu and it is working will i have to modify that also to work with the dynamic route.
Sorry I don't know anything about your cms framework but in Laravel you cant use the same name for two bindings in your route, they must each be unique.
Route::get('/{categoyrySlug}/{subcategorySlug}', 'Site\CategoryController#show')->name('category.show');
And in Site\CategoryController you should be able to use :
public function show($categorySlug, $subcategorySlug){
...
}
and then handle them accodingly.

Laravel Paypal checkout

Json view of my paypal after payment is made
I am desperately trying to access the description which is under the transactions array but can't seem to find a way!
It's totally different if I want to access payment_method for instance all I do is this:
(By the way, I assigned this array to $method)
$method->payer->payment_method , but the same thing doesn't work if I want to access description. All I get is an error.
I'm using laravel 5.5, in case that makes a difference.
I'm doing this because I need to find a way to reference my product in the final page after the paypal payment has been made.
Looks like transactions in an array so if you would like the description of the first one that would look like this.
$method->transactions[0]->description

parse variable from view to controller laravel-backpack

im using Laravel-Backpack. could we parse some param from view to backpack controller? imagine i have some list of a package. each package has 5 round so every package has 5 button in its row. when i click first button(round 1) it will open the list of item that has round_id = 1.
what can i think is each round button in package list will parse id to route that will call backpackCrud Controller. and that id will used for advance queries for the item list
my button
<i>2</i>
my route
CRUD::resource('package/round/{RoundId}', 'Admin\CrudController');
my crud controller
$round= \Route::current()->parameter('RoundId');
$this->crud->addClause('where', 'round', '=', $round);
but it return an error
Route pattern "/admin/package/round/{RoundId}/{{RoundId}}" cannot reference variable name "RoundId" more than once.
what i know is we cannot parse param to restfull controller cause restfull is for quick crud. so what should i do for parse id from view to controller. or maybe there is beautifull way to make the queries? i trully appreciate that
Many thanks!
i found the way to avoid that.
it CANNOT be like:
CRUD::resource('package/round/{RoundId}', 'Admin\CrudController');
we have to follow the pattern of the default route like
CRUD::resource('someRoute/{someId}/someSecondRoute{someSecondId}', 'Admin\CrudController');
with that way, we can get the first and second paramater in controller with this:
$firstParam= \Route::current()->parameter('someID');
$SecondParam= \Route::current()->parameter('someSecondID');
hope this help someone else ;)

Calling Model->Method() within blade templates

I asked this on the Laravel 4.x forum and tried to find the answer on Google without any luck.
I'm using Eloquent to load a bunch of user objects that have a created_at property. The default MySQL timestamp isn't very readable, so I thought it would be neat to add a readableDate() method to my User model which would output the value as "1 minute ago", "2 days ago" instead.
When I call on the method in my blade templates like: $user->readableDate() I get the desired output but my whole layout is broken.
Is it, or should it be possible to call on a model method from within a template?
If you're using Laravel's Eloquent models, you do not need to add custom methods for handling dates. By default, date fields such as created_at and updated_at are handled as a Carbon objects, which allows you to display the date in a human readable format:
{{ $user->created_at->diffForHumans() }}
You can add additional date fields to your Eloquent model with the getDates() method.
Yes, blade is compiled to PHP. :)
You just have to:
Pass your user to your view:
return View::make('showUser')->with('user', $user);
And then use it:
<hml><body>
Last update: {{ $user->readableDate() }}
</body></hml>
Can I assume you are wrapping it inside blade tags {{ code here }}, or did you miss that part?
Also, your model should be called using the static approach like this:
{{ User::readableDate() }}
ok, I figured this out. What I was trying to do is possible but it was throwing an error that I couldn't see. When I viewed the source of the page the usual laravel error HTML was below my output. The error was being thrown by default values in the created_at field.

way to pass variable through url in codeigniter

I got a big search module in my Codeigniter project. Well simply I am passing variable to a view like
<a href=<?php echo site_url('controller/view/1'); ?>>View List</a>
And fetching its data in controller like
$id=$this->uri->segment(3);
For pagination
http://wwww.site.com/controller/view/<filter id>/<page from>
This is working perfectly in the case of simple query.
Now I got some more filter quires like
Country
State
City
Customer type
etc etc
then the url should be
http://wwww.site.com/controller/view/1/id2/id3/i4/id5
Is this the correct way to do the process ? If not please give a little advice...
I am new to codeigniter
The problem you are facing i have recently found a solution for this.
When you are first sending parameters through url use POST instead.
When you get the parameters you can pass them to session in a variable
type. Next time when you paginate get the type value from session and
put it in your query to get the desired result.
If you have more than 1 parameters you can put them in sessions and
unset them on certain conditions so that they are not called in every query.
I think the best approach here is to create another method in the controller something like filtered_view that accepts a filter_id and a page number, and that methode will fetch the data from the database with the provided filter and you'll use your pagination class as usual.
Hope this help.

Resources