Skip to content

Instantly share code, notes, and snippets.

View aeroreyna's full-sized avatar
🌴
Love my ocupation

Adolfo Reyna aeroreyna

🌴
Love my ocupation
View GitHub Profile
@aeroreyna
aeroreyna / README.md
Created June 24, 2020 17:28
Miva: Add a product to basket with a custom price.

Miva: Add a product to basket with a custom price.

The following code allows us to add any product to the basket, using the product code, with an specified price. No items required.

I'm exploring this route to implement a donation items, given the freedom to customer to put any amount for it.

<mvt:assign name="g.Product_code" value="'g.product_code'" />
@aeroreyna
aeroreyna / README.md
Created June 19, 2020 05:23
Miva Most Frequently Purchased Products of the Customer.

Miva Most Frequently Purchased Products of the Customer.

Taking advantaje of the query function from the free toolbelt module, we can query information directly from the database. This function provide us, as developers, much more freedom to work with the store data, such as stadistical information of the products that the current customer has bought more times.

By taking into account the preference of a recurrent customer, it is likely that he would like to purchase similar products on his next visit. So offering these in a ordered manner could improve the customer quality of experience.

@aeroreyna
aeroreyna / README.md
Created June 17, 2020 03:56
Miva add basket to the last customer order

Miva add basket to the last customer order

Check if the customer is logged in and if the parameter addToLast has been assignated to 1. Then Reads the last order of the current logged in customer. Update the local basket information to include the order id and the basket id, and uses the function OrderItem_Copy_Basket provided by Miva. This function does not update the order total, so that is carried manually. And finally the basket is cleared of all items.

NOTE: I'm testing this approach, It might mess with something I'm not aware of, use caution.

@aeroreyna
aeroreyna / README.md
Last active June 12, 2020 04:31
Miva create wishlist using customer's email

Miva Create Wishlist with Customer Email

We can make a template page with the code exposed below, and call the page either from the fron-end or back-end with the following parameters:

  • customer_email
  • wname
  • wnote
  • shared
@aeroreyna
aeroreyna / README.md
Last active June 11, 2020 22:35
Miva All Customer's Wishlists Items

Miva All Customer's Wishlists Items

By using the free toolbelt module, we can query the database directly to query the join table of the wishlist, wishlistitems (with product codes) of the currently logged customer.

The following code can be use on a page template, with the toolbelt item on. It returns a Json of the wishlists items.

<mvt:item name="ry_toolbelt" param="assign|g.select_sql|'SELECT t1.title, t1.notes AS wishnotes,  t2.*, t3.code AS product_code FROM s01_WishLists t1 JOIN s01_WishListItems t2 JOIN s01_Products t3 WHERE t1.id = t2.wshlst_id AND t2.product_id = t3.id AND cust_id = `' $ MySqlEscape(g.Basket:cust_id) $ '`'" />
<mvt:do name="l.result" file="g.Module_Feature_TUI_MGR" value="TemplateManager_Render_Page( 'PAGECODE' )" />
@aeroreyna
aeroreyna / README.md
Created June 10, 2020 19:04
Miva Product Full Information JSON

Miva Product Full Information JSON

A Miva page template that returns the full information of a product (basic, image, custom fields and variants) as json.

Example data:

{
  "active": 1,
 "agrpcount": 0,
@aeroreyna
aeroreyna / README.md
Last active June 10, 2020 03:35
Vue.js Minibasket for Miva

A Vue.js implementation for a minisbasket section on Miva.

By making use of the Miva JSON module, we can store the information in a Javascript variable basket. We can build a Vue.js template around this variable to display the information that we want to show to the customers. Then, this information can be updated (for example when adding products) using ajax, avoiding a page refresh, which improves the customer experience. Happier customers, tend to buy more stuff.

This template makes use of a page that returns the current minibasket information in Json format GlobalMinisbasket.json.

An improved version of this minibasket is used on the FoodRelated store.

@aeroreyna
aeroreyna / GLOBALBASK_JSON.html
Last active June 10, 2020 03:15
MIVA Globla Basket Json
<mvt:assign name="l.header" value="miva_output_header( 'Content-type', 'application/json' )" />
<mvt:do file="g.Module_JSON" name="l.success" value="JSON_Output(l.settings:global_minibasket)" />
//With out any server or php modification.
$.get("https://ejample.com/wp-json/wp/v2/posts?callback=?",(json)=>{
console.log(json)
});